Package org.redisson.api
Interface RJsonStore<K,V>
- Type Parameters:
K- the type of keyV- the type of value
- All Superinterfaces:
RExpirable,RExpirableAsync,RJsonStoreAsync<K,,V> RObject,RObjectAsync
JSON Store which stores each entry as key and value. Both are POJO objects.
Value is stored as JSON datatype in Redis.
The implementation is available in Redisson PRO only.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionintaddListener(ObjectListener listener) Adds object event listenerlongarrayAppend(K key, String path, Object... values) Appends values to array by specified key and JSONPath.arrayAppendMulti(K key, String path, Object... values) Appends values to arrays by specified key and JSONPath.longarrayIndex(K key, String path, Object value) Returns index of object in array by specified key and JSONPathlongarrayIndex(K key, String path, Object value, long start, long end) Returns index of object in array by specified key and JSONPath in range betweenstart(inclusive) andend(exclusive) indexesarrayIndexMulti(K key, String path, Object value) Returns index of object in arrays by specified key and JSONPatharrayIndexMulti(K key, String path, Object value, long start, long end) Returns index of object in arrays by specified key and JSONPath in range betweenstart(inclusive) andend(exclusive) indexeslongarrayInsert(K key, String path, long index, Object... values) Inserts values into array by specified key and JSONPath.arrayInsertMulti(K key, String path, long index, Object... values) Inserts values into arrays by specified key and JSONPath.<T> TarrayPollFirst(K key, JsonCodec codec, String path) Polls first element of array by specified key and JSONPath.<T> List<T> arrayPollFirstMulti(K key, JsonCodec codec, String path) Polls first element of arrays by specified key and JSONPath.<T> TarrayPollLast(K key, JsonCodec codec, String path) Polls last element of array by specified key and JSONPath.<T> List<T> arrayPollLastMulti(K key, JsonCodec codec, String path) Polls last element of arrays by specified key and JSONPath.<T> TPops element located at index of array by specified key and JSONPath.<T> List<T> arrayPopMulti(K key, JsonCodec codec, String path, long index) Pops elements located at index of arrays by specified key and JSONPath.longReturns size of array by specified key and JSONPath.arraySizeMulti(K key, String path) Returns size of arrays by specified key and JSONPath.longTrims array by specified key and JSONPath in range betweenstart(inclusive) andend(inclusive) indexes.arrayTrimMulti(K key, String path, long start, long end) Trims arrays by specified key and JSONPath in range betweenstart(inclusive) andend(inclusive) indexes.longClears json container by specified keys and JSONPath.longClears json containers by specified keys.booleanClears value by specified keybooleancompareAndSet(K key, String path, Object expect, Object update) Atomically sets the value to the given updated value by specified key and JSONPath, only if serialized state of the current value equals to serialized state of the expected value.booleancompareAndSet(K key, V expect, V update) Atomically sets the value to the given updated value by specified key only if serialized state of the current value equals to serialized state of the expected value.booleancontainsKey(Object key) Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalselongReturns keys amount in JSON container by specified keylongReturns keys amount in JSON container specified by key and JSONPathcountKeysMulti(K key, String path) Returns list of keys amount in JSON containers specified by key and JSONPathlongDeletes JSON elements specified by keys and JSONPathlongDeletes entries by specified keysbooleanDeletes entry by specified keyRetrieves values by specified keys and JSONPath.Retrieves values by specified keys.Retrieves value by specified key.<T> TGets value by specified key and JSONPathgetAndClearExpire(K key) Retrieves current value by specified key and clears expiration date set before.getAndDelete(K key) Retrieves entry value by specified key and removes it.getAndExpire(K key, Duration duration) Retrieves current value by specified key and sets an expiration duration for it.getAndExpire(K key, Instant time) Retrieves current value by specified key and sets an expiration date for it.<T> TRetrieves current value stored by specified key and JSONPath then replaces it with new value.Retrieves current value by specified key and replaces it with new value.Retrieves current value by specified key and replaces it with value and defines expirationduration.getCountDownLatch(K key) ReturnsRCountDownLatchinstance associated with keygetFairLock(K key) ReturnsRLockinstance associated with keyReturns list of keys in JSON container by specified keyReturns list of keys in JSON container by specified key and JSONPathgetKeysMulti(K key, String path) Returns list of keys in JSON containers by specified key and JSONPathReturnsRLockinstance associated with keyReturnsRPermitExpirableSemaphoreinstance associated with keygetReadWriteLock(K key) ReturnsRReadWriteLockinstance associated with keygetSemaphore(K key) ReturnsRSemaphoreinstance associated with keyReturns type of valueReturns type of element specified by key and JSONPath<T extends Number>
TincrementAndGet(K key, String path, T delta) Increments the current value specified by key and JSONPath.incrementAndGetMulti(K key, String path, T delta) Increments the current values specified by key and JSONPath.keySet()Returns key set of this map.keySet(int count) Returns key set of this map.Returns key set of this map.Returns key set of this map.voidMerges value into element by the specified key and JSONPath.Read all keys at oncelongremainTimeToLive(K key) Remaining time to live of map entry associated with akey.voidStores values by specified keys and JSONPath.voidStores values by specified keys.voidStores values by specified keys with defined expiration duration.voidStores value by specified key and JSONPath.voidStores value by specified key.voidStores value by specified key with defined expiration duration.voidsetAndKeepTTL(K key, V value) Sets value by specified key and keep existing TTL.booleansetIfAbsent(K key, String path, Object value) Sets value by specified key and JSONPath only if previous value is empty.booleansetIfAbsent(K key, V value) Sets value only if entry doesn't exist.booleansetIfAbsent(K key, V value, Duration duration) Sets value with defined duration only if entry doesn't exist.booleansetIfExists(K key, String path, Object value) Sets value by specified key and JSONPath only if previous value is non-empty.booleansetIfExists(K key, V value) Sets value only if entry already exists.booleansetIfExists(K key, V value, Duration duration) Setsvaluewith expirationdurationonly if entry already exists.intsize()Returns entries amount in storelongsizeInMemory(K key) Returns size of entry in bytes specified by key.longstringAppend(K key, String path, Object value) Appends string data to element specified by specified key and JSONPath.stringAppendMulti(K key, String path, Object value) Appends string data to elements specified by specified key and JSONPath.stringSize(K key, String path) Returns size of string data by specified key and JSONPathstringSizeMulti(K key, String path) Returns list of string data size by specified key and JSONPath.booleanToggle boolean value by specified key and JSONPathtoggleMulti(K key, String path) Toggle boolean values by specified key and JSONPathMethods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLiveMethods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsyncMethods inherited from interface org.redisson.api.RJsonStoreAsync
addListenerAsync, arrayAppendAsync, arrayAppendMultiAsync, arrayIndexAsync, arrayIndexAsync, arrayIndexMultiAsync, arrayIndexMultiAsync, arrayInsertAsync, arrayInsertMultiAsync, arrayPollFirstAsync, arrayPollFirstMultiAsync, arrayPollLastAsync, arrayPollLastMultiAsync, arrayPopAsync, arrayPopMultiAsync, arraySizeAsync, arraySizeMultiAsync, arrayTrimAsync, arrayTrimMultiAsync, clearAsync, clearAsync, clearAsync, compareAndSetAsync, compareAndSetAsync, containsKeyAsync, countKeysAsync, countKeysAsync, countKeysMultiAsync, deleteAsync, deleteAsync, deleteAsync, getAndClearExpireAsync, getAndDeleteAsync, getAndExpireAsync, getAndExpireAsync, getAndSetAsync, getAndSetAsync, getAndSetAsync, getAsync, getAsync, getAsync, getAsync, getKeysAsync, getKeysAsync, getKeysMultiAsync, getTypeAsync, getTypeAsync, incrementAndGetAsync, incrementAndGetMultiAsync, mergeAsync, readAllKeySetAsync, remainTimeToLiveAsync, setAndKeepTTLAsync, setAsync, setAsync, setAsync, setAsync, setAsync, setAsync, setIfAbsentAsync, setIfAbsentAsync, setIfAbsentAsync, setIfExistsAsync, setIfExistsAsync, setIfExistsAsync, sizeAsync, sizeInMemoryAsync, stringAppendAsync, stringAppendMultiAsync, stringSizeAsync, stringSizeMultiAsync, toggleAsync, toggleMultiAsyncMethods inherited from interface org.redisson.api.RObject
copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlinkMethods inherited from interface org.redisson.api.RObjectAsync
copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Method Details
-
get
Gets value by specified key and JSONPath- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- entry value codecpaths- JSON paths- Returns:
- entry value
-
setIfAbsent
Sets value by specified key and JSONPath only if previous value is empty.- Parameters:
key- entry keypath- JSON pathvalue- entry value- Returns:
trueif successful, orfalseif value was already set
-
setIfExists
Sets value by specified key and JSONPath only if previous value is non-empty.- Parameters:
key- entry keypath- JSON pathvalue- object- Returns:
trueif successful, orfalseif element wasn't set
-
compareAndSet
Atomically sets the value to the given updated value by specified key and JSONPath, only if serialized state of the current value equals to serialized state of the expected value.- Parameters:
key- entry keypath- JSON pathexpect- the expected valueupdate- the new value- Returns:
trueif successful; orfalseif the actual value was not equal to the expected value.
-
getAndSet
Retrieves current value stored by specified key and JSONPath then replaces it with new value.- Parameters:
key- entry keycodec- entry value codecpath- JSON pathnewValue- value to set- Returns:
- previous value
-
set
Stores value by specified key and JSONPath.- Parameters:
key- entry keypath- JSON pathvalue- value to set
-
stringSize
Returns size of string data by specified key and JSONPath- Parameters:
key- entry keypath- JSON path- Returns:
- size of string
-
stringSizeMulti
Returns list of string data size by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON path- Returns:
- list of string data sizes
-
stringAppend
Appends string data to element specified by specified key and JSONPath. Returns new size of string data.- Parameters:
key- entry keypath- JSON pathvalue- data- Returns:
- size of string data
-
stringAppendMulti
Appends string data to elements specified by specified key and JSONPath. Returns new size of string data. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathvalue- data- Returns:
- list of string data sizes
-
arrayAppend
Appends values to array by specified key and JSONPath. Returns new size of array.- Parameters:
key- entry keypath- JSON pathvalues- values to append- Returns:
- size of array
-
arrayAppendMulti
Appends values to arrays by specified key and JSONPath. Returns new size of arrays. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathvalues- values to append- Returns:
- list of arrays size
-
arrayIndex
Returns index of object in array by specified key and JSONPath. -1 means object not found.- Parameters:
key- entry keypath- JSON pathvalue- value to search- Returns:
- index in array
-
arrayIndexMulti
Returns index of object in arrays by specified key and JSONPath. -1 means object not found. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathvalue- value to search- Returns:
- list of index in arrays
-
arrayIndex
Returns index of object in array by specified key and JSONPath in range betweenstart(inclusive) andend(exclusive) indexes. -1 means object not found.- Parameters:
key- entry keypath- JSON pathvalue- value to searchstart- start index, inclusiveend- end index, exclusive- Returns:
- index in array
-
arrayIndexMulti
Returns index of object in arrays by specified key and JSONPath in range betweenstart(inclusive) andend(exclusive) indexes. -1 means object not found. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathvalue- value to searchstart- start index, inclusiveend- end index, exclusive- Returns:
- list of index in arrays
-
arrayInsert
Inserts values into array by specified key and JSONPath. Values are inserted at definedindex.- Parameters:
key- entry keypath- JSON pathindex- array index at which values are insertedvalues- values to insert- Returns:
- size of array
-
arrayInsertMulti
Inserts values into arrays by specified key and JSONPath. Values are inserted at definedindex. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathindex- array index at which values are insertedvalues- values to insert- Returns:
- list of arrays size
-
arraySize
Returns size of array by specified key and JSONPath.- Parameters:
key- entry keypath- JSON path- Returns:
- size of array
-
arraySizeMulti
Returns size of arrays by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON path- Returns:
- list of arrays size
-
arrayPollLast
Polls last element of array by specified key and JSONPath.- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- object codecpath- JSON path- Returns:
- last element
-
arrayPollLastMulti
Polls last element of arrays by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- object codecpath- JSON path- Returns:
- list of last elements
-
arrayPollFirst
Polls first element of array by specified key and JSONPath.- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- object codecpath- JSON path- Returns:
- first element
-
arrayPollFirstMulti
Polls first element of arrays by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- object codecpath- JSON path- Returns:
- list of first elements
-
arrayPop
Pops element located at index of array by specified key and JSONPath.- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- object codecpath- JSON pathindex- array index- Returns:
- element
-
arrayPopMulti
Pops elements located at index of arrays by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Type Parameters:
T- the type of object- Parameters:
key- entry keycodec- object codecpath- JSON pathindex- array index- Returns:
- list of elements
-
arrayTrim
Trims array by specified key and JSONPath in range betweenstart(inclusive) andend(inclusive) indexes.- Parameters:
key- entry keypath- JSON pathstart- start index, inclusiveend- end index, inclusive- Returns:
- length of array
-
arrayTrimMulti
Trims arrays by specified key and JSONPath in range betweenstart(inclusive) andend(inclusive) indexes. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathstart- start index, inclusiveend- end index, inclusive- Returns:
- length of array
-
clear
Clears value by specified key- Parameters:
key- entry key- Returns:
trueif successful, orfalseif entry doesn't exist
-
clear
Clears json containers by specified keys.- Parameters:
keys- entry keys- Returns:
- number of cleared containers
-
clear
Clears json container by specified keys and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Parameters:
path- JSON pathkeys- entry keys- Returns:
- number of cleared containers
-
incrementAndGet
Increments the current value specified by key and JSONPath.- Parameters:
key- entry keypath- JSON pathdelta- increment value- Returns:
- the updated value
-
incrementAndGetMulti
Increments the current values specified by key and JSONPath. Compatible only with enhanced syntax starting with '$' character.- Parameters:
key- entry keypath- JSON pathdelta- increment value- Returns:
- list of updated value
-
merge
Merges value into element by the specified key and JSONPath.- Parameters:
key- entry keypath- JSON pathvalue- value to merge
-
countKeys
Returns keys amount in JSON container by specified key- Parameters:
key- entry key- Returns:
- keys amount
-
countKeys
Returns keys amount in JSON container specified by key and JSONPath- Parameters:
key- entry keypath- JSON path- Returns:
- keys amount
-
countKeysMulti
Returns list of keys amount in JSON containers specified by key and JSONPath- Parameters:
key- entry keypath- JSON path- Returns:
- list of keys amount
-
getKeys
Returns list of keys in JSON container by specified key- Returns:
- list of keys
-
getKeys
Returns list of keys in JSON container by specified key and JSONPath- Parameters:
path- JSON path- Returns:
- list of keys
-
getKeysMulti
Returns list of keys in JSON containers by specified key and JSONPath- Parameters:
path- JSON path- Returns:
- list of keys
-
toggle
Toggle boolean value by specified key and JSONPath- Parameters:
path- JSON path- Returns:
- new boolean value
-
toggleMulti
Toggle boolean values by specified key and JSONPath- Parameters:
path- JSON path- Returns:
- list of boolean values
-
getType
Returns type of value- Returns:
- type of element
-
getType
Returns type of element specified by key and JSONPath- Parameters:
path- JSON path- Returns:
- type of element
-
delete
Deletes entry by specified key- Parameters:
key- entry key- Returns:
trueif successful, orfalseif entry doesn't exist
-
delete
Deletes entries by specified keys- Parameters:
keys- entry keys- Returns:
- number of deleted elements
-
delete
Deletes JSON elements specified by keys and JSONPath- Parameters:
path- JSON pathkeys- entry keys- Returns:
- number of deleted elements
-
sizeInMemory
Returns size of entry in bytes specified by key.- Parameters:
key- entry key- Returns:
- entry size
-
get
Retrieves value by specified key.- Parameters:
key- entry key- Returns:
- element
-
get
Retrieves values by specified keys.- Parameters:
keys- entry keys- Returns:
- map with entries where value mapped by key
-
get
Retrieves values by specified keys and JSONPath.- Parameters:
path- JSON pathkeys- entry keys- Returns:
- map with entries where value mapped by key
-
getAndDelete
Retrieves entry value by specified key and removes it.- Parameters:
key- entry key- Returns:
- element
-
setIfAbsent
Sets value only if entry doesn't exist.- Parameters:
key- entry keyvalue- value to set- Returns:
trueif successful, orfalseif element was already set
-
setIfAbsent
Sets value with defined duration only if entry doesn't exist.- Parameters:
key- entry keyvalue- value to setduration- expiration duration- Returns:
trueif successful, orfalseif element was already set
-
setIfExists
Sets value only if entry already exists.- Parameters:
key- entry keyvalue- value to set- Returns:
trueif successful, orfalseif element wasn't set
-
setIfExists
Setsvaluewith expirationdurationonly if entry already exists.- Parameters:
key- entry keyvalue- value to setduration- expiration duration- Returns:
trueif successful, orfalseif element wasn't set
-
compareAndSet
Atomically sets the value to the given updated value by specified key only if serialized state of the current value equals to serialized state of the expected value.- Parameters:
key- entry keyexpect- the expected valueupdate- the new value- Returns:
trueif successful; orfalseif the actual value was not equal to the expected value.
-
getAndSet
Retrieves current value by specified key and replaces it with new value.- Parameters:
key- entry keynewValue- value to set- Returns:
- previous value
-
getAndSet
Retrieves current value by specified key and replaces it with value and defines expirationduration.- Parameters:
key- entry keyvalue- value to setduration- expiration duration- Returns:
- previous value
-
getAndExpire
Retrieves current value by specified key and sets an expiration duration for it.Requires Redis 6.2.0 and higher.
- Parameters:
key- entry keyduration- of object time to live interval- Returns:
- value
-
getAndExpire
Retrieves current value by specified key and sets an expiration date for it.Requires Redis 6.2.0 and higher.
- Parameters:
key- entry keytime- of exact object expiration moment- Returns:
- value
-
getAndClearExpire
Retrieves current value by specified key and clears expiration date set before.Requires Redis 6.2.0 and higher.
- Parameters:
key- entry key- Returns:
- value
-
set
Stores value by specified key.- Parameters:
key- entry keyvalue- value to set
-
set
Stores values by specified keys.- Parameters:
entries- entries to store
-
set
Stores values by specified keys and JSONPath.- Parameters:
path- JSONPathentries- entries to store
-
set
Stores value by specified key with defined expiration duration.- Parameters:
key- entry keyvalue- value to setduration- expiration duration
-
set
Stores values by specified keys with defined expiration duration.- Parameters:
entries- entries to storeduration- expiration duration
-
setAndKeepTTL
Sets value by specified key and keep existing TTL.Requires Redis 6.0.0 and higher.
- Parameters:
value- value to set
-
addListener
Adds object event listener- Specified by:
addListenerin interfaceRObject- Parameters:
listener- object event listener- Returns:
- listener id
- See Also:
-
remainTimeToLive
Remaining time to live of map entry associated with akey.- Parameters:
key- - map key- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
keySet
Returns key set of this map. Keys are loaded in batch. Batch size is10.- Returns:
- key set
- See Also:
-
keySet
Returns key set of this map. Keys are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of keys batch- Returns:
- key set
- See Also:
-
keySet
Returns key set of this map. Ifpatternis not null then only keys match this pattern are loaded. Keys are loaded in batch. Batch size is defined bycountparam.Use
org.redisson.client.codec.StringCodecfor Map keys.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
pattern- - key patterncount- - size of keys batch- Returns:
- key set
- See Also:
-
keySet
Returns key set of this map. Ifpatternis not null then only keys match this pattern are loaded.Use
org.redisson.client.codec.StringCodecfor Map keys.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
pattern- - key pattern- Returns:
- key set
- See Also:
-
containsKey
Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalse- Parameters:
key- - map key- Returns:
trueif this map contains map entry mapped by specifiedkey, otherwisefalse
-
readAllKeySet
Read all keys at once- Returns:
- keys
-
size
int size()Returns entries amount in store- Returns:
- entries amount
-
getCountDownLatch
ReturnsRCountDownLatchinstance associated with key- Parameters:
key- - map key- Returns:
- countdownlatch
-
getPermitExpirableSemaphore
ReturnsRPermitExpirableSemaphoreinstance associated with key- Parameters:
key- - map key- Returns:
- permitExpirableSemaphore
-
getSemaphore
ReturnsRSemaphoreinstance associated with key- Parameters:
key- - map key- Returns:
- semaphore
-
getFairLock
ReturnsRLockinstance associated with key- Parameters:
key- - map key- Returns:
- fairlock
-
getReadWriteLock
ReturnsRReadWriteLockinstance associated with key- Parameters:
key- - map key- Returns:
- readWriteLock
-
getLock
ReturnsRLockinstance associated with key- Parameters:
key- - map key- Returns:
- lock
-