Commit f74099d7 authored by 赵威's avatar 赵威

save data to redis

parent db6097cd
...@@ -66,7 +66,6 @@ object Main { ...@@ -66,7 +66,6 @@ object Main {
val a = ES.request(diaryReq) val a = ES.request(diaryReq)
Redis.save(ES.request(diaryReq), deviceId, "diary") Redis.save(ES.request(diaryReq), deviceId, "diary")
// ES.test(diaryReq, tractateReq, answerReq, serviceDiaryReq) // ES.test(diaryReq, tractateReq, answerReq, serviceDiaryReq)
println("########################") println("########################")
......
...@@ -10,15 +10,12 @@ object Redis { ...@@ -10,15 +10,12 @@ object Redis {
val pRc4 = new RedisClient("172.16.50.145", 6379, 0, Some("XfkMCCdWDIU%ls$h"), 5000) val pRc4 = new RedisClient("172.16.50.145", 6379, 0, Some("XfkMCCdWDIU%ls$h"), 5000)
def save(content: Future[IndexedSeq[Content]], deviceId: String, contentType: String): Unit = { def save(contentF: Future[IndexedSeq[Content]], deviceId: String, contentType: String): Unit = {
val key = s"streaming:candidate:${contentType}:device_id:${deviceId}" val key = s"streaming:candidate:${contentType}:device_id:${deviceId}"
println(key) pRc4.del(key)
contentF.foreach { seq =>
val a = content.map { seq => pRc4.lpush(key, seq.map(c => c.id))
seq.map { c => pRc4.expire(key, 60 * 60 * 24 * 15)
println(c.id)
c.id
}
} }
} }
} }
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