使用Hazelcast时如何处理高速缓存踩踏?

发布于 2025-02-01 11:09:40 字数 236 浏览 2 评论 0原文

我的春季服务是使用Hazelcast(嵌入式群集)作为本地缓存。

当缓存由于TTL而到期时,如果一次有大量用户请求,请求将转移到DB以更新缓存。 (缓存Stampede)

出于这个原因,我考虑了应用每个算法,但是据我的理解,当缓存到期时间可能不同时,算法似乎是有意义的。 但是,似乎无法应用Hazelcast群集缓存,因为它使用了按群集同步的缓存。那是对的吗?

那么,Hazlecast应采取什么策略来处理缓存踩踏?

My spring service is using hazelcast(embedded cluster) as local cache.

When the cache expires due to TTL, if a large number of user requests come at once, the requests are transferred to the DB to update the cache. (cache stampede)

For this reason, I thought about applying the PER algorithm, but from my understanding, the algorithm seems to be meaningful when the cache expiration time can be different for each node.
However, it seems that hazelcast cluster cache cannot be applied because it uses a cache synchronized on a per-cluster basis. Is that correct?

So, what strategy should hazlecast take to handle cache stampede?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜扑 2025-02-08 11:09:40

Hazelcast提供了以下方法:

put(K, V, long, java.util.concurrent.TimeUnit)

它允许您在执行级别上指定TTL。您可以在某个间隔中随机将值随机化,以防止高速缓存踩踏。

Hazelcast provides the following method:

put(K, V, long, java.util.concurrent.TimeUnit)

which allows you to specify a TTL on per-entry level. You can e.g. randomize the value in some interval which would prevent the cache stampede.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文