【发布时间】:2019-07-05 03:53:02
【问题描述】:
我将 hashmap 缓存到 redis 并以以下方式读取特定的 hashkey:
var hashValue = redis.HashGet(rediskey, hashkey) // RedisCall#1
if (hashValue == null && !redis.KeyExist(rediskey)) // RedisCall#2
{
// load from sql and cache it to redis
}
else
{
return hashValue;
}
我试图避免我必须对 redis 进行 2 次调用。请就如何解决这个问题提出建议,并在一个 redis 调用中做到这一点。
【问题讨论】:
标签: performance caching optimization redis stackexchange.redis