New2Java
New2Java

Reputation: 313

How do I replicate Redisson’s RScoredSortedSet behavior in Oracle Coherence - Equivalent Implementation

I need to migrate from Redis to Oracle Coherence and looking for the best way to replicate Redis's RScoredSortedSet functionality. Take a look at the below code:

private RScoredSortedSet<Long> getScoredSet(String key) {
    RScoredSortedSet<Long> rssSet = redissonClient.getScoredSortedSet(key);
    
    if(!rssSet.isExists()) {
        RLock lock = redissonClient.getLock("lockKey");
        if(lock.tryLock(1, 20, TimeUnit.SECONDS)) {
            try {
                rssSet.clear();
                // Add score-value pairs
                rssSet.add(score, value);
            } finally {
                lock.unlock();
            }
        }
    }
    return rssSet;
}

My Question:

  1. What’s the best way to simulate a scored sorted set in Coherence (i.e. storing elements with scores and maintaining order, Support for operations like clear() and add(score, value))?
  2. How can I implement distributed locking in Coherence similar to the use of RLock in Redisson?

I'm new to Coherence and Any guidance on how to achieve this in Coherence would be much appreciated.

Upvotes: 0

Views: 33

Answers (0)

Related Questions