I am using the StackExchange.Redis 1.0.450 nuget in C#. I have code like below which checks if a keyexists in redis before adding it -
if (!Cache.KeyExists(fKey))
{
Cache.StringSet(fKey, Serialize(data));
}
where Cache is Database object
I was reading about the redis SET command here http://redis.io/commands/set and found that SET will overwrite existing key value if it already exists. Using StackExchange.Redis can I safely remove the exist check condition and call just -
Cache.StringSet(fKey, Serialize(data));
Appreciate your response.
yes, you can savely remove that. We also don't check for existence as that would lead to have two access points to the cache where only one is necessary. This would really slow down cache access.
You may want to consider three other things: