Timeout is a very typical operation that you usually come across all the time, In my case there were few options I had to get around this issue (I was using tornado for handling requests, and Redis for storage):
Last night I sat with this idea in my mind to have a PUBLISH event on a configured channel when a key expires (Cure for the itch). Walking around Redis community I found some really complicated discussions going on; with ideas of meta publish channels and some really brainy ideas stuff. I wanted to keep it simple, clean, configurable and that’s where opensource really helps; you have a different opinion go create your own flavor. I created my own fork and implemented what was really simple (and yummy chocolate flavored :P). So with new fork, Redis configuration can now contain an additional parameter named keys-expire-notify (so keys-expire-notify !KEYS will make Redis do a “PUBLISH !KEYS <expired_key>” every-time a key expires).
This feature will open up a whole new world of possibilities for the Redis users, including DB updates on cache invalidation, cascaded updates in Redis, time out events from Redis (Yes you can use keys to make it happen), Imagination is your limit! I’ve been playing around with the thing for a bit longer now and I am pretty much satisfied. It should be pretty much stable, since its built on top of existing infrastructure. You can grab your copy here and enjoy the new feature! I am really looking forward to see this idea as official part of Redis.