Package me.ahoo.cosid.spring.redis
Class SpringRedisIdSegmentDistributor
java.lang.Object
me.ahoo.cosid.spring.redis.SpringRedisIdSegmentDistributor
- All Implemented Interfaces:
Grouped
,IdSegmentDistributor
Spring Redis IdSegmentDistributor.
-
Nested Class Summary
Nested classes/interfaces inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
IdSegmentDistributor.Atomic, IdSegmentDistributor.Mock
-
Field Summary
Fields inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
DEFAULT_OFFSET, DEFAULT_SEGMENTS, DEFAULT_STEP
-
Constructor Summary
ConstructorsConstructorDescriptionSpringRedisIdSegmentDistributor
(String namespace, String name, long offset, long step, org.springframework.data.redis.core.StringRedisTemplate redisTemplate) SpringRedisIdSegmentDistributor
(String namespace, String name, org.springframework.data.redis.core.StringRedisTemplate redisTemplate) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
allowReset, getNamespacedName, getStep, nextIdSegment, nextIdSegment, nextIdSegment, nextIdSegmentChain, nextIdSegmentChain, nextMaxId
-
Constructor Details
-
SpringRedisIdSegmentDistributor
-
SpringRedisIdSegmentDistributor
-
-
Method Details
-
getAdderKey
-
getNamespace
Description copied from interface:IdSegmentDistributor
Get the namespace for this distributor.The namespace provides a logical grouping for ID segments, allowing multiple independent segment spaces within the same system.
- Specified by:
getNamespace
in interfaceIdSegmentDistributor
- Returns:
- The namespace
-
getName
Description copied from interface:IdSegmentDistributor
Get the name for this distributor.The name uniquely identifies this distributor within its namespace.
- Specified by:
getName
in interfaceIdSegmentDistributor
- Returns:
- The name
-
getOffset
public long getOffset() -
getStep
public long getStep()Description copied from interface:IdSegmentDistributor
Get the step size for ID segments.The step size determines how many IDs are allocated in each segment. Larger steps reduce coordination overhead but may lead to ID gaps.
- Specified by:
getStep
in interfaceIdSegmentDistributor
- Returns:
- The step size
-
nextMaxId
public long nextMaxId(long step) Description copied from interface:IdSegmentDistributor
Allocate the next maximum ID for the specified step size.This method allocates a new range of IDs by returning the maximum ID in the allocated range. The range starts at the previous maximum plus one and ends at the returned value.
- Specified by:
nextMaxId
in interfaceIdSegmentDistributor
- Parameters:
step
- The step size for allocation- Returns:
- The maximum ID in the allocated range
-