title: Redis and redis-py: Storing abstract objects
body: <p>In Python I have objects that contain other objects. What is the best way to represent this using Redis?</p>
  
  <p><a href="https://stackoverflow.com/a/15220010/1950164">This answer</a> adresses this. The solution is basically that you give every object an id and if a objectA contains objectB what you store in objectA is the id of objectB. If there's nothing better, I guess this seems reasonable.</p>
  
  <p>Now my question is, how do I generate these ids? Lets say that my objects are users that contain other objects called items. Each unique item I give a unique id. But when a new item is created, how to I make sure that the id I give the new item doesn't exist already, without having to check the all the existing ids? Suppoose for example that I'm storying all the existing items in the redis namespace as item:int, item:5313, item:1234 etc. I want to create a new item, how do I check the existing ids in a way that's efficient?</p>
  
  <p>Thanks.</p>