0
我試圖強制我的redis客戶端超時測試目的,我未能實現如此。我在我的配置中將超時指定爲2ms,並且我執行的設置操作需要> 2ms,爲什麼它不超時?這些設置是一種軟設置而不是強制執行?我使用Jedis 2.6和Scala 2.10播放2.2.3強制Redis超時
@Singleton
class RedisClient extends Cache {
// set timeout
val TIMEOUT = 2
private val pool = new JedisPool(new JedisPoolConfig(), getStringFromConfig("redis.url"), getIntFromConfig("redis.port"), TIMEOUT);
def isOpen = pool.getNumActive()
def set(key: String, value: String) = {
isOpen match {
case -1 => throw new Exception("Redis server is not running")
case _ => {
val jedis = pool.getResource()
val before = Platform.currentTime
jedis.set(key, value)
println("TIME TAKEN " + (Platform.currentTime - before))
pool.returnResource(jedis)
}
}
}
}