ruby on rails - Can I use HINCRBY/INCR in Redis to guarantee an integer response? -


i'm using redis-objects gem implement counters on rails models. of counters singular (so modeled counter foo backed single redis value) others have number of keys, modeled hash_key bar , backed redis hash hincrby.

so far good, values returned hash strings, not ints, because redis-objects doesn't know hash counter. .to_i results, result in unpredictable behavior if key overwritten non-int value, example.

can use hincrby myhash field 0 force redis interpret field value int64 , produce integer reply (:1..) semantics compatible normal increment? cause lock or other undesirable behavior related using "write" op read? there better way cast read?


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -