TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Lock and cache using Redis

19 点作者 seamusabshere超过 9 年前

3 条评论

jconley超过 9 年前
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.
AznHisoka超过 9 年前
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 未加载
troutwine超过 9 年前
Hmm, wait, maybe I&#x27;m misunderstanding. Why would you want to serialize all concurrent actors on a cache read?
评论 #10570984 未加载