Commit 2b454c03 authored by 赵威's avatar 赵威

add reoad

parent aef54307
......@@ -33,7 +33,8 @@ object Main {
// val query = ES.generateServiceDiaryRequest(List("光子嫩肤", "水光针"), List("丰胸", "胸部塑身"), -1)
// println("###############")
Redis.getRead("abc", "diary")
val res = Redis.getRead("64695DE0-B926-4188-9C62-D987DC20BEDF", "diary")
res.foreach(println)
// val env = StreamExecutionEnvironment.getExecutionEnvironment
......
package com.gmei.up.utils
import scala.concurrent.Future
import scala.collection.JavaConverters._
import com.alibaba.fastjson.JSON
import com.redis.{ RedisClient, RedisClientPool }
object Redis {
......@@ -10,32 +12,14 @@ object Redis {
val pRc2 = new RedisClient("172.16.40.173", 6379, 0, Some("ReDis!GmTx*0aN9"), 5000)
// def get_user_portrait_tag3_read_v2(device_id: str, content_type: str) -> Tuple[List[Any], List[Any]]:
// key = get_user_portrait_tag3_read_key_v2(device_id, content_type)
// date_list_dict = await redis_client2.hgetall(key)
// read_list_v2 = []
// today_read = []
// if date_list_dict:
// before_5_days_date = get_before_5_days_date()
// today_read = json.loads(date_list_dict.get(before_5_days_date[0].encode(), '[]'))
// # 删除5天以外的已读记录
// for day in date_list_dict:
// day_decode = day.decode()
// if day_decode in before_5_days_date:
// read_list_v2.extend(json.loads(date_list_dict[day]))
// else:
// await redis_client2.hdel(key, day)
// res = (read_list_v2, today_read)
// return res
val pRc4 =
new RedisClientPool("172.16.50.145", 6379, database = 0, secret = Some("XfkMCCdWDIU%ls$h"), timeout = 500)
def getRead(deviceId: String, contentType: String): Unit = {
def getRead(deviceId: String, contentType: String): List[Long] = {
val key = s"doris:user_portrait:tag3:read_v2:device_id:${deviceId}:content_type:${contentType}"
val today = java.time.LocalDate.now.toString()
val res = pRc2.hget(key, today)
println(res)
val redisRes = pRc2.hget(key, today)
redisRes.map(s => JSON.parseArray(s, classOf[Long]).asScala.toList).getOrElse(List.empty[Long])
}
def save(contentF: Future[IndexedSeq[Content]], deviceId: String, contentType: String): Unit = {
......
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