TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Lock and cache using Redis

19 pointsby seamusabshereover 9 years ago

3 comments

jconleyover 9 years ago
So this is for read through caching with distributed locking. There are a couple scenarios where this is interesting.<p>1) If calculating the item in the cache is so expensive to some system, and might happen so many times concurrently, that you&#x27;d rather block than duplicate work. 2) There is something not-idempotent about the operation you are blocking on.<p>But, coming from experience, be very very very very careful with distributed locking and put lots of logging&#x2F;monitoring&#x2F;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.
AznHisokaover 9 years ago
I already use Redis-Mutex for such use cases: <a href="https:&#x2F;&#x2F;github.com&#x2F;kenn&#x2F;redis-mutex" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kenn&#x2F;redis-mutex</a><p>What&#x27;s the difference?
评论 #10571097 未加载
troutwineover 9 years ago
Hmm, wait, maybe I&#x27;m misunderstanding. Why would you want to serialize all concurrent actors on a cache read?
评论 #10570984 未加载