Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pipeline and transaction #47

Merged
merged 10 commits into from
May 15, 2024
Merged

Add pipeline and transaction #47

merged 10 commits into from
May 15, 2024

Conversation

CahidArda
Copy link
Collaborator

@CahidArda CahidArda commented May 9, 2024

Adding pipeline and transaction feature as described in #45.

Majority of the update is complete. Next steps:

  • Docstrings
  • Context manager usage (with redis.pipeline() as pipe: ...)
  • Benchmarking
  • Auto pipelining for asyncio

Copy link

linear bot commented May 9, 2024

I had used flushdb in fixtures of pipeline tests. This removed data put into the db in conftest.py before all tests run, making other tests fail.

Instead of flushdb, deleting keys by name
@CahidArda
Copy link
Collaborator Author

CahidArda commented May 10, 2024

to benchmark the pipeline, I tried sending 100 incrby commands back to back

Code Pure redis:
t1 = time.time()
iter_count = 100
for i in range(iter_count):
    redis.incrby("marine", 10)
val = redis.get("marine")
assert val == str(iter_count*10)

t2 = time.time()
print(t2-t1)

Pipeline:

import time

t1 = time.time()
iter_count = 100
with redis.multi() as pipeline:
    for i in range(iter_count):
        pipeline.incrby("marine", 10)
val = redis.get("marine")
assert val == str(iter_count*10)

t2 = time.time()
print(t2-t1)

Runtimes:

Normal Pipeline Transcation
5.28 s 0.31 s 0.34 s

upstash_redis/asyncio/client.py Outdated Show resolved Hide resolved
upstash_redis/asyncio/client.py Outdated Show resolved Hide resolved
upstash_redis/asyncio/client.py Outdated Show resolved Hide resolved
@CahidArda CahidArda marked this pull request as ready for review May 14, 2024 14:13
upstash_redis/client.py Show resolved Hide resolved
upstash_redis/client.py Outdated Show resolved Hide resolved
upstash_redis/asyncio/client.py Outdated Show resolved Hide resolved
upstash_redis/http.py Outdated Show resolved Hide resolved
upstash_redis/http.py Outdated Show resolved Hide resolved
@CahidArda CahidArda merged commit 1f5943e into main May 15, 2024
1 check passed
@mdumandag mdumandag deleted the DX-882 branch May 15, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants