我正在将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的两个电话。请建议您如何解决这个问题,并在一个redis调用。