Commit 42353274 authored by 赵威's avatar 赵威

update redisclient

parent 6bf9045d
package com.gmei.up.utils
import scala.concurrent.Future
import com.redis.RedisClient
import com.redis.{ RedisClient, RedisClientPool }
object Redis {
// TODO read from config file
implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global
val pRc4 = new RedisClient("172.16.50.145", 6379, 0, Some("XfkMCCdWDIU%ls$h"), 5000)
val pRc4 =
new RedisClientPool("172.16.50.145", 6379, database = 0, secret = Some("XfkMCCdWDIU%ls$h"), timeout = 500)
def save(contentF: Future[IndexedSeq[Content]], deviceId: String, contentType: String): Unit = {
val key = s"streaming:candidate:${contentType}:device_id:${deviceId}"
println(key)
contentF.foreach { seq =>
val ids = seq.map(c => c.id)
if (ids.size > 0) {
pRc4.del(key)
ids.foreach { id =>
println(id)
pRc4.rpush(key, id)
pRc4.withClient { client =>
contentF.foreach { seq =>
val ids = seq.map(c => c.id)
if (ids.size > 0) {
client.del(key)
ids.foreach { id =>
println(id)
client.rpush(key, id)
}
client.expire(key, 60 * 60 * 24 * 15)
}
pRc4.expire(key, 60 * 60 * 24 * 15)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment