Distributed sequence number generation?

后端 未结 13 1895
小鲜肉
小鲜肉 2020-11-29 14:32

I\'ve generally implemented sequence number generation using database sequences in the past.

e.g. Using Postgres SERIAL type http://www.neilconway.o

13条回答
  •  [愿得一人]
    2020-11-29 15:17

    It can be done with Redisson. It implements distributed and scalable version of AtomicLong. Here is example:

    Config config = new Config();
    config.addAddress("some.server.com:8291");
    
    Redisson redisson = Redisson.create(config);
    RAtomicLong atomicLong = redisson.getAtomicLong("anyAtomicLong");
    atomicLong.incrementAndGet();
    

提交回复
热议问题