title: Set a value to a key with ttl
body: <p>Is it possible to setnx a key with a value and a ttl in single command in redis</p>
  
  <p>I am trying to implement locking in redis and <a href="http://redis.io/commands/hsetnx" rel="nofollow">http://redis.io/commands/hsetnx</a> seems like the best way to do that. It is atomic and returns 0 if a key is already present. Is it possible to HSETNX with TTL</p>
  
  <p>e.g.</p>
  
  <pre><code>HSETNX myhash mykey "myvalue" 10
  
  #and key expires after 10 seconds, and a subsequent HSETNX after 10 seconds returns a value 1 i.e. it behaves as if mykey is not present in myhash
  </code></pre>