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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -