Class InMemoryJSentinelVersionStore
java.lang.Object
com.svenruppert.jsentinel.session.InMemoryJSentinelVersionStore
- All Implemented Interfaces:
JSentinelVersionStore
@ExperimentalJSentinelApi
public final class InMemoryJSentinelVersionStore
extends Object
implements JSentinelVersionStore
In-memory
JSentinelVersionStore backed by a
ConcurrentHashMap. Atomic increments through
ConcurrentHashMap.compute(Object, java.util.function.BiFunction).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the currentJSentinelVersionassociated withkey.Atomically bumps the version forkeyby one and returns the new value.voidreset(JSentinelVersionKey key) Resets the version forkeytoJSentinelVersion.INITIAL.
-
Constructor Details
-
InMemoryJSentinelVersionStore
public InMemoryJSentinelVersionStore()Creates an empty store.
-
-
Method Details
-
current
Description copied from interface:JSentinelVersionStoreReturns the currentJSentinelVersionassociated withkey. ReturnsJSentinelVersion.INITIALwhen the key has never been incremented (i.e. the subject is fresh).- Specified by:
currentin interfaceJSentinelVersionStore- Parameters:
key- tenant + subject; must not benull- Returns:
- current version, never
null
-
increment
Description copied from interface:JSentinelVersionStoreAtomically bumps the version forkeyby one and returns the new value. The very first call on a key transitionsJSentinelVersion.INITIALto value1.- Specified by:
incrementin interfaceJSentinelVersionStore- Parameters:
key- tenant + subject; must not benull- Returns:
- the new (post-increment) version
-
reset
Description copied from interface:JSentinelVersionStoreResets the version forkeytoJSentinelVersion.INITIAL. No-op when no value was ever recorded.- Specified by:
resetin interfaceJSentinelVersionStore- Parameters:
key- tenant + subject; must not benull
-