c# - Is exists check required before calling StringSet method of StrackExchange.Redis -
i using stackexchange.redis 1.0.450 nuget in c#. have code below checks if keyexists in redis before adding -
if (!cache.keyexists(fkey)) { cache.stringset(fkey, serialize(data)); }
where cache database object
i reading redis set command here http://redis.io/commands/set , found set overwrite existing key value if exists. using stackexchange.redis can safely remove exist check condition , call -
cache.stringset(fkey, serialize(data));
appreciate response.
yes, can savely remove that. don't check existence lead have 2 access points cache 1 necessary. slow down cache access.
you may want consider 3 other things:
- you may have make set action repeatable in case redis cache not available in moment of access.
- you may have make initialization of connection repeatable
- please refer buffer redis stream how make (de)serialization of redis cache entries reliable , fast.
Comments
Post a Comment