我正在将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;
}
我试图避免必须打2次来给redis打电话。请提出建议,以解决您将如何解决此问题的问题,并只需一个redis调用即可完成。