Make use of StrictRedis.set() parameters ex and nx. #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?