3 ms·
Show HN: Lock and cache using Redis
- troutwine 11y agoHmm, wait, maybe I'm misunderstanding. Why would you want to serialize all concurrent actors on a cache read?
- jconley 11y agoSo this is for read through caching with distributed locking. There are a couple scenarios where this is interesting. 1) If calculating the item in the cache is so expensive to some system, and might happen so many times concurrently, that you'd rather block than duplicate work. 2) There is something not-idempotent about the operation you are blocking on. But, coming from experience, be very very very very careful with distributed locking and put lots of logging/monitoring/timeouts around it if you have to do it. Avoid it if possible. Try hard to use a different persistent data structure, store, or algorithm that makes the locking irrelevant.
- AznHisoka 11y agoI already use Redis-Mutex for such use cases: https://github.com/kenn/redis-mutex https://github.com/kenn/redis-mutex What's the difference?
- jconley 11y agoLooks like this uses a Ruby version of redlock under the hood: http://redis.io/topics/distlock http://redis.io/topics/distlock Seems to be just a little abstraction so you don't manage the locks yourself.
- deleted 11y ago[deleted]