Brian Trezise
11/15/2018, 1:34 PMBrian Trezise
11/15/2018, 1:36 PMBrian Trezise
11/15/2018, 1:36 PMBrian Trezise
11/15/2018, 3:14 PMphldavies
11/15/2018, 5:48 PMRedisOperations<K, V>
interface. This should show you the approach: @Component
class MyRedisComponent(private val redisTemplate: StringRedisTemplate) {
fun addStuffWithExt() {
val txResults = redisTemplate.executeSession { operations ->
operations.multi()
operations.opsForSet().add("key", "value1")
operations.exec()
}
}
}
fun <K : Any, V : Any, T : Any?> RedisOperations<K, V>.executeSession(session: (RedisOperations<K, V>) -> T): T? =
execute(object : SessionCallback<T> {
@Suppress("UNCHECKED_CAST")
override fun <K2 : Any?, V2 : Any?> execute(operations: RedisOperations<K2, V2>): T =
session(operations as RedisOperations<K, V>)
})
Brian Trezise
11/17/2018, 8:55 PM