Created
December 25, 2024 07:59
-
-
Save vndee/97db1c9859ab310485db7549490954b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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