Redissed

Redis Kotlin wrapper inspired on Exposed

Лицензия

Лицензия

Категории

Категории

Redis Данные Базы данных
Группа

Группа

br.com.devsrsouza
Идентификатор

Идентификатор

redissed
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Redissed
Redis Kotlin wrapper inspired on Exposed
Ссылка на сайт

Ссылка на сайт

https://github.com/DevSrSouza/Redissed
Система контроля версий

Система контроля версий

https://github.com/DevSrSouza/Redissed/tree/master/

Скачать redissed

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/br.com.devsrsouza/redissed/ -->
<dependency>
    <groupId>br.com.devsrsouza</groupId>
    <artifactId>redissed</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/br.com.devsrsouza/redissed/
implementation 'br.com.devsrsouza:redissed:1.1.0'
// https://jarcasting.com/artifacts/br.com.devsrsouza/redissed/
implementation ("br.com.devsrsouza:redissed:1.1.0")
'br.com.devsrsouza:redissed:jar:1.1.0'
<dependency org="br.com.devsrsouza" name="redissed" rev="1.1.0">
  <artifact name="redissed" type="jar" />
</dependency>
@Grapes(
@Grab(group='br.com.devsrsouza', module='redissed', version='1.1.0')
)
libraryDependencies += "br.com.devsrsouza" % "redissed" % "1.1.0"
[br.com.devsrsouza/redissed "1.1.0"]

Зависимости

runtime (1)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.41

Модули Проекта

Данный проект не имеет модулей.

. Redissed

Redis Kotlin wrapper inspired on Exposed

Getting started

Gradle

dependencies {
    compile("br.com.devsrsouza:redissed:1.1.0")
}

Maven

<dependency>
    <groupId>br.com.devsrsouza</groupId>
    <artifactId>redissed</artifactId>
    <version>1.1.0</version>
</dependency>

Sample

import br.com.devsrsouza.redissed.RedisObject

class MyObject(database: String, commands: RedissedCommands) : RedisObject(database, commands) {
  var hello: String? by string()
  var hi: String by string("Hi")

  val other: OtherObject by obj { OtherObject(it, commands) }
}

class OtherObject(database: String, commands: RedissedCommands) : RedisObject(database, commands) {
  var something = string()

  var points: Int = int(0)
}

val database = "my:db"
val commands: RedissedCommands = myClient.redissed

val my = MyObject("$database:obj", commands)

my.hello = "Hello" // setting "Hello" to my:db:obj:hello
my.hi // getting my:db:obj:hi from Redis if not exist return default "Hi"

my.hello = null // removing data from my:db:obj:hello

my.other.something = "Anything" // setting "Anything" to my:db:obj:other:something
my.other.points = 10 // setting 10 to my:db:obj:other:points

Supported Redis Clients

  • Jedis
  • Lettuce

Jedis

import br.com.devsrsouza.redissed.clients.redissed
import br.com.devsrsouza.redissed.RedissedCommands

val jedis = Jedis("localhost", 6379)
jedis.connect()

val commands: RedissedCommands = jedis.redissed

Lettuce

import br.com.devsrsouza.redissed.clients.redissed
import br.com.devsrsouza.redissed.RedissedCommands

val redis = RedisClient.create(RedisURI.create("localhost", 6379))
val conn = redis.connect()
val sync = conn.sync()

val commands: RedissedCommands = sync.redissed

Supported types

string(): String?
string(default: String): String
byte(): Byte?
byte(default: Byte): Byte
short(): Short?
short(default: Short): Short
int(): Int?
int(default: Int): Int
long(): Long?
long(default: Long): Long
boolean(): Boolean?
boolean(default: Boolean): Boolean
obj(factory: (key: String) -> RedisObject): RedisObject

Expire

Auto expires a key

var your_key: String? by string().expire(5) // in seconds

You can use withExpire to tell the expiration time for a specific value or get the expiration time of a value

var my_key: Pair<String, Int> by string("my default key").withExpire()

my_key = "my new value expiring in 10 sec" to 10

// get the expiration time of a key
val (value, time) = my_key
// returns the expiration time in seconds or
// returns -2 if the key does not exist.
// returns -1 if the key exists but has no associated expire. 

Версии библиотеки

Версия
1.1.0
1.0.0
0.1.1