有没有类似于跳表的分布式缓存解决方案?

发布于 2024-10-10 07:51:10 字数 741 浏览 0 评论 0原文

我想知道是否有任何开源(或专有)框架可以模拟并发优先级队列,该队列允许以良好的性能查看和从任意索引中删除。

现在我正在使用 JDK 中提供的 ConcurrentSkipList,但基本上我需要在多个 JVM 之间共享它。

最困难的部分是,当我轮询队列时,我正在做这样的事情:

List<Entry> dequeued = new ArrayList<>(thisManyIwant);
for(Entry entry : queue){
    if(dequeued.size()>=thisManyIwant) break;
    if(predicate.apply(entry)){
        // Entry satisfies criteria
        if(queue.remove(entry){
            // OK, got it
            dequeued.add(entry);
        }else{
            // damn, somebody took it before I could :(
        }
    }else{
        // It's not something I want, move on to the next one.
    }
}
return dequeued;

一些分布式缓存允许查询,但此操作是性能密集型的,我不确定大量查询缓存是否是一个好主意。

有人听说过这样的事情吗?

I was wondering if there are any open source (or proprietary) frameworks that would simulate a concurrent priority queue which allows peeking, and removal from arbitrary index with good performance.

Right now I'm using ConcurrentSkipList available in JDK, but basically I need to share this across multiple JVMs.

The most difficult part is, when I poll the queue I'm doing something like this:

List<Entry> dequeued = new ArrayList<>(thisManyIwant);
for(Entry entry : queue){
    if(dequeued.size()>=thisManyIwant) break;
    if(predicate.apply(entry)){
        // Entry satisfies criteria
        if(queue.remove(entry){
            // OK, got it
            dequeued.add(entry);
        }else{
            // damn, somebody took it before I could :(
        }
    }else{
        // It's not something I want, move on to the next one.
    }
}
return dequeued;

Some distributed cache allows querying, but this operation is performance intensive and I wasn't sure if querying the cache a lot would be a good idea.

Does anybody have heard of such thing?

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

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

发布评论

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

评论(1

空城缀染半城烟沙 2024-10-17 07:51:10

你看过 Hazelcast

我担心我只使用了 Map 实现,所以我不知道是否支持你需要的模式。

Have you looked at Hazelcast

I'm affraid I've only used the Map implementation so I don't know if it supports the pattern you require.

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