How can I get a unique long from Gemfire?

后端 未结 1 1589
予麋鹿
予麋鹿 2021-01-23 13:04

We are working on a layered Java application that talks directly to Gemfire.

We need to be able to generate unique \"long\" sequence numbers, guaranteed unique across al

相关标签:
1条回答
  • 2021-01-23 13:50

    The first question to ask yourself is do you really need a long sequence number (monotonically increasing long integer) or do you just need a globally unique identifier (like a UUID).

    The most performant solution is going to be a globally unique id and I would just suggest using a GUID.

    If you need a globally unique monotonically increasing long value (long sequence) then you will have to use some distributed locking and increment a value in the region. The method for this and performance depends on the type of region you are using.

    Look at Region.replace(K, V, V). It can perform globally atomic updates to values under specific region definitions. You may need to consider a region that just has your sequences if your current region type is not sufficiently defined.

    0 讨论(0)
提交回复
热议问题