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 support for older redis versions #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

petrubabalau
Copy link

No description provided.

@@ -95,7 +99,17 @@ async def _acquire(self) -> None:
pipeline = self._backend.pipeline()

async with self._lock:
current_rate = await self._run_pipeline(cache_key, pipeline)
redis_version = await self.redis_version()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this earlier? We don't need to query this every time. We only need this once per app.

redis_version = await self.redis_version()

if int(redis_version.split('.')[0]) < 7:
current_rate, *_ = await pipeline.incr(cache_key).execute()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like you execute a pipeline twice. This might not be safe due to race conditions.

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