title: redis: set if exist - via python
body: <p>I've got a huge list of keys and one value (the same for all keys) that should be written to a redis instance. This should only be happen, if an entry with this key already exists.</p>
  
  <p>There is the <a href="http://redis.io/commands/msetnx" rel="nofollow">MSETNX</a> command which is doing the opposite: putting in the entry, when the key does <strong>NOT</strong> exist.</p>
  
  <p>Sure, i can just check before via <a href="http://redis.io/commands/exists" rel="nofollow">EXIST</a> and set it depending on the result, but how do i ensure that this atomic. And as this list can be really huge, how do i do this the pipeline-based?</p>
  
  <p>i'am using <a href="https://github.com/andymccurdy/redis-py/" rel="nofollow">redis-py</a> as wrapper and there's no Lua-Scripting support available on the server.</p>