有没有类似于跳表的分布式缓存解决方案?
我想知道是否有任何开源(或专有)框架可以模拟并发优先级队列,该队列允许以良好的性能查看和从任意索引中删除。
现在我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你看过 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.