Skip to content

Instantly share code, notes, and snippets.

@vndee
Created December 25, 2024 07:59
Show Gist options
  • Save vndee/97db1c9859ab310485db7549490954b2 to your computer and use it in GitHub Desktop.
Save vndee/97db1c9859ab310485db7549490954b2 to your computer and use it in GitHub Desktop.
# Traditional local structure - simple but not distributed
local_queue = []
local_queue.append(task) # What happens if our process crashes?
# Raw Redis approach - distributed but verbose
redis_conn.lpush("queue", json.dumps(task)) # How do we handle types?
task = json.loads(redis_conn.lpop("queue")) # What about error handling?
# Redis Data Structures - best of both worlds
from redis_data_structures import Queue
queue = Queue()
queue.push("tasks", task) # Clean API, distributed, type-safe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment