ericrasmussen/pyramid_redis_sessions — pull request #48 by whiteroses (2014-07-13 18:17:15+00:00)
Title: Make use of StrictRedis.set() parameters ex and nx.

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

As discussed here: https://github.com/ericrasmussen/pyramid_redis_sessions/pull/37#issuecomment-48098440. 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?