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

Make use of StrictRedis.set() parameters ex and nx. #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Make use of StrictRedis.set() parameters ex and nx. #48

wants to merge 1 commit into from

Conversation

whiteroses
Copy link
Contributor

These parameters were introduced in Redis 2.6.12 and redis-py 2.7.4.

As discussed here: #37 (comment). A PR for you for whenever you feel ready to drop support for redis-py < 2.7.4.

Working on this raised another issue: you may remember we talked a while back about some concerns I had with race conditions. Haven't had time to look more into them, but changing the persist decorator for this pull request I noticed again that it doesn't make sure the key already exists in Redis before persisting. Which I really think it should, because otherwise it would just write a session into Redis where it doesn't exist, like the scenario we talked about where request A invalidates the session and deletes it from Redis and request B then just writes its copy of the session back in, undoing the invalidate. Looking at the .set() parameters, xx=True would do it nicely and simply. What do you think? If you agree, what exception would you want it to raise if the session is no longer in Redis?

Introduced in Redis 2.6.12 and redis-py 2.7.4.
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.

1 participant