Distributed Concurrency Control

前端 未结 13 1824
栀梦
栀梦 2021-01-29 20:35

I\'ve been working on this for a few days now, and I\'ve found several solutions but none of them incredibly simple or lightweight. The problem is basically this: We have a cl

13条回答
  •  野性不改
    2021-01-29 21:11

    I recommend to use Redisson. It implements over 30 distributed data structures and services including java.util.Lock. Usage example:

    Config config = new Config();
    config.addAddress("some.server.com:8291");
    Redisson redisson = Redisson.create(config);
    
    Lock lock = redisson.getLock("anyLock");
    lock.lock();
    try {
        ...
    } finally {
       lock.unlock();
    }
    
    redisson.shutdown();
    

提交回复
热议问题