com.lightningkite.lightningserver.cache.RedisTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-redis Show documentation
Show all versions of server-redis Show documentation
A set of tools to fill in/replace what Ktor is lacking in.
package com.lightningkite.lightningserver.cache
import io.lettuce.core.RedisClient
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.take
import org.junit.AfterClass
import org.junit.Assert.assertEquals
import org.junit.BeforeClass
import org.junit.Test
import redis.embedded.RedisServer
class RedisTest: CacheTest() {
override val cache: Cache? by lazy {
RedisCache(RedisClient.create("redis://127.0.0.1:6379/0"))
}
companion object {
lateinit var redisServer: RedisServer
@JvmStatic
@BeforeClass
fun start() {
redisServer = RedisServer.builder()
.port(6379)
.setting("bind 127.0.0.1") // good for local development on Windows to prevent security popups
.slaveOf("localhost", 6379)
.setting("daemonize no")
.setting("appendonly no")
.setting("replica-read-only no")
.setting("maxmemory 128M")
.build()
redisServer.start()
}
@JvmStatic
@AfterClass
fun stop() {
redisServer.stop()
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy