title: Can I use HINCRBY/INCR in Redis to guarantee an integer response?
body: <p>I'm using the <a href="https://github.com/nateware/redis-objects" rel="nofollow">redis-objects</a> gem to implement some counters on rails models. Some of the counters are singular (so modeled like <code>counter foo</code> backed by a single redis value) but others could have some number of keys, modeled as <code>hash_key bar</code> and backed by a redis hash with <code>HINCRBY</code>.</p>
  
  <p>So far so good, however the values returned from the hash are strings, not ints, because redis-objects doesn't know that the hash is a counter. I could just <code>.to_i</code> the results, but this could result in unpredictable behavior if a key was overwritten by a non-int value, for example.</p>
  
  <p>Can I use <code>HINCRBY myhash field 0</code> to force redis to interpret the field value as an int64 and produce an Integer reply (<code>:1..</code>) with semantics compatible with normal increment? Will this cause a lock or other undesirable behavior related to using a "write" op as a read? Is there a better way to cast the read?</p>