Skip to content

Instantly share code, notes, and snippets.

@tbarbugli
Created January 10, 2013 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbarbugli/4503482 to your computer and use it in GitHub Desktop.
Save tbarbugli/4503482 to your computer and use it in GitHub Desktop.
create a unique timestamp (with a namespace)
import time
def get_unique_timestamp(redis_connection, uniqueness_namespace):
while True:
t = time.time()
key = namespace % t
if redis_connection.setnx(key):
return key
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment