Interface RJsonStore<K,V>

Type Parameters:
K - the type of key
V - the type of value
All Superinterfaces:
RExpirable, RExpirableAsync, RJsonStoreAsync<K,V>, RObject, RObjectAsync

public interface RJsonStore<K,V> extends RExpirable, RJsonStoreAsync<K,V>
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 Details

    • get

      <T> T get(K key, JsonCodec codec, String... paths)
      Gets value by specified key and JSONPath
      Type Parameters:
      T - the type of object
      Parameters:
      key - entry key
      codec - entry value codec
      paths - JSON paths
      Returns:
      entry value
    • setIfAbsent

      boolean setIfAbsent(K key, String path, Object value)
      Sets value by specified key and JSONPath only if previous value is empty.
      Parameters:
      key - entry key
      path - JSON path
      value - entry value
      Returns:
      true if successful, or false if value was already set
    • setIfExists

      boolean setIfExists(K key, String path, Object value)
      Sets value by specified key and JSONPath only if previous value is non-empty.
      Parameters:
      key - entry key
      path - JSON path
      value - object
      Returns:
      true if successful, or false if element wasn't set
    • compareAndSet

      boolean compareAndSet(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.
      Parameters:
      key - entry key
      path - JSON path
      expect - the expected value
      update - the new value
      Returns:
      true if successful; or false if the actual value was not equal to the expected value.
    • getAndSet

      <T> T getAndSet(K key, JsonCodec codec, String path, Object newValue)
      Retrieves current value stored by specified key and JSONPath then replaces it with new value.
      Parameters:
      key - entry key
      codec - entry value codec
      path - JSON path
      newValue - value to set
      Returns:
      previous value
    • set

      void set(K key, String path, Object value)
      Stores value by specified key and JSONPath.
      Parameters:
      key - entry key
      path - JSON path
      value - value to set
    • stringSize

      Long stringSize(K key, String path)
      Returns size of string data by specified key and JSONPath
      Parameters:
      key - entry key
      path - JSON path
      Returns:
      size of string
    • stringSizeMulti

      List<Long> stringSizeMulti(K key, String path)
      Returns list of string data size by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      key - entry key
      path - JSON path
      Returns:
      list of string data sizes
    • stringAppend

      long stringAppend(K key, String path, Object value)
      Appends string data to element specified by specified key and JSONPath. Returns new size of string data.
      Parameters:
      key - entry key
      path - JSON path
      value - data
      Returns:
      size of string data
    • stringAppendMulti

      List<Long> stringAppendMulti(K key, String path, Object value)
      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 key
      path - JSON path
      value - data
      Returns:
      list of string data sizes
    • arrayAppend

      long arrayAppend(K key, String path, Object... values)
      Appends values to array by specified key and JSONPath. Returns new size of array.
      Parameters:
      key - entry key
      path - JSON path
      values - values to append
      Returns:
      size of array
    • arrayAppendMulti

      List<Long> arrayAppendMulti(K key, String path, Object... values)
      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 key
      path - JSON path
      values - values to append
      Returns:
      list of arrays size
    • arrayIndex

      long arrayIndex(K key, String path, Object value)
      Returns index of object in array by specified key and JSONPath. -1 means object not found.
      Parameters:
      key - entry key
      path - JSON path
      value - value to search
      Returns:
      index in array
    • arrayIndexMulti

      List<Long> arrayIndexMulti(K key, String path, Object value)
      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 key
      path - JSON path
      value - value to search
      Returns:
      list of index in arrays
    • arrayIndex

      long arrayIndex(K key, String path, Object value, long start, long end)
      Returns index of object in array by specified key and JSONPath in range between start (inclusive) and end (exclusive) indexes. -1 means object not found.
      Parameters:
      key - entry key
      path - JSON path
      value - value to search
      start - start index, inclusive
      end - end index, exclusive
      Returns:
      index in array
    • arrayIndexMulti

      List<Long> arrayIndexMulti(K key, String path, Object value, long start, long end)
      Returns index of object in arrays by specified key and JSONPath in range between start (inclusive) and end (exclusive) indexes. -1 means object not found. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      key - entry key
      path - JSON path
      value - value to search
      start - start index, inclusive
      end - end index, exclusive
      Returns:
      list of index in arrays
    • arrayInsert

      long arrayInsert(K key, String path, long index, Object... values)
      Inserts values into array by specified key and JSONPath. Values are inserted at defined index.
      Parameters:
      key - entry key
      path - JSON path
      index - array index at which values are inserted
      values - values to insert
      Returns:
      size of array
    • arrayInsertMulti

      List<Long> arrayInsertMulti(K key, String path, long index, Object... values)
      Inserts values into arrays by specified key and JSONPath. Values are inserted at defined index. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      key - entry key
      path - JSON path
      index - array index at which values are inserted
      values - values to insert
      Returns:
      list of arrays size
    • arraySize

      long arraySize(K key, String path)
      Returns size of array by specified key and JSONPath.
      Parameters:
      key - entry key
      path - JSON path
      Returns:
      size of array
    • arraySizeMulti

      List<Long> arraySizeMulti(K key, String path)
      Returns size of arrays by specified key and JSONPath. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      key - entry key
      path - JSON path
      Returns:
      list of arrays size
    • arrayPollLast

      <T> T arrayPollLast(K key, JsonCodec codec, String path)
      Polls last element of array by specified key and JSONPath.
      Type Parameters:
      T - the type of object
      Parameters:
      key - entry key
      codec - object codec
      path - JSON path
      Returns:
      last element
    • arrayPollLastMulti

      <T> List<T> arrayPollLastMulti(K key, JsonCodec codec, String path)
      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 key
      codec - object codec
      path - JSON path
      Returns:
      list of last elements
    • arrayPollFirst

      <T> T arrayPollFirst(K key, JsonCodec codec, String path)
      Polls first element of array by specified key and JSONPath.
      Type Parameters:
      T - the type of object
      Parameters:
      key - entry key
      codec - object codec
      path - JSON path
      Returns:
      first element
    • arrayPollFirstMulti

      <T> List<T> arrayPollFirstMulti(K key, JsonCodec codec, String path)
      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 key
      codec - object codec
      path - JSON path
      Returns:
      list of first elements
    • arrayPop

      <T> T arrayPop(K key, JsonCodec codec, String path, long index)
      Pops element located at index of array by specified key and JSONPath.
      Type Parameters:
      T - the type of object
      Parameters:
      key - entry key
      codec - object codec
      path - JSON path
      index - array index
      Returns:
      element
    • arrayPopMulti

      <T> List<T> arrayPopMulti(K key, JsonCodec codec, String path, long index)
      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 key
      codec - object codec
      path - JSON path
      index - array index
      Returns:
      list of elements
    • arrayTrim

      long arrayTrim(K key, String path, long start, long end)
      Trims array by specified key and JSONPath in range between start (inclusive) and end (inclusive) indexes.
      Parameters:
      key - entry key
      path - JSON path
      start - start index, inclusive
      end - end index, inclusive
      Returns:
      length of array
    • arrayTrimMulti

      List<Long> arrayTrimMulti(K key, String path, long start, long end)
      Trims arrays by specified key and JSONPath in range between start (inclusive) and end (inclusive) indexes. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      key - entry key
      path - JSON path
      start - start index, inclusive
      end - end index, inclusive
      Returns:
      length of array
    • clear

      boolean clear(K key)
      Clears value by specified key
      Parameters:
      key - entry key
      Returns:
      true if successful, or false if entry doesn't exist
    • clear

      long clear(Set<K> keys)
      Clears json containers by specified keys.
      Parameters:
      keys - entry keys
      Returns:
      number of cleared containers
    • clear

      long clear(String path, Set<K> keys)
      Clears json container by specified keys and JSONPath. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      path - JSON path
      keys - entry keys
      Returns:
      number of cleared containers
    • incrementAndGet

      <T extends Number> T incrementAndGet(K key, String path, T delta)
      Increments the current value specified by key and JSONPath.
      Parameters:
      key - entry key
      path - JSON path
      delta - increment value
      Returns:
      the updated value
    • incrementAndGetMulti

      <T extends Number> List<T> incrementAndGetMulti(K key, String path, T delta)
      Increments the current values specified by key and JSONPath. Compatible only with enhanced syntax starting with '$' character.
      Parameters:
      key - entry key
      path - JSON path
      delta - increment value
      Returns:
      list of updated value
    • merge

      void merge(K key, String path, Object value)
      Merges value into element by the specified key and JSONPath.
      Parameters:
      key - entry key
      path - JSON path
      value - value to merge
    • countKeys

      long countKeys(K key)
      Returns keys amount in JSON container by specified key
      Parameters:
      key - entry key
      Returns:
      keys amount
    • countKeys

      long countKeys(K key, String path)
      Returns keys amount in JSON container specified by key and JSONPath
      Parameters:
      key - entry key
      path - JSON path
      Returns:
      keys amount
    • countKeysMulti

      List<Long> countKeysMulti(K key, String path)
      Returns list of keys amount in JSON containers specified by key and JSONPath
      Parameters:
      key - entry key
      path - JSON path
      Returns:
      list of keys amount
    • getKeys

      List<String> getKeys(K key)
      Returns list of keys in JSON container by specified key
      Returns:
      list of keys
    • getKeys

      List<String> getKeys(K key, String path)
      Returns list of keys in JSON container by specified key and JSONPath
      Parameters:
      path - JSON path
      Returns:
      list of keys
    • getKeysMulti

      List<List<String>> getKeysMulti(K key, String path)
      Returns list of keys in JSON containers by specified key and JSONPath
      Parameters:
      path - JSON path
      Returns:
      list of keys
    • toggle

      boolean toggle(K key, String path)
      Toggle boolean value by specified key and JSONPath
      Parameters:
      path - JSON path
      Returns:
      new boolean value
    • toggleMulti

      List<Boolean> toggleMulti(K key, String path)
      Toggle boolean values by specified key and JSONPath
      Parameters:
      path - JSON path
      Returns:
      list of boolean values
    • getType

      JsonType getType(K key)
      Returns type of value
      Returns:
      type of element
    • getType

      JsonType getType(K key, String path)
      Returns type of element specified by key and JSONPath
      Parameters:
      path - JSON path
      Returns:
      type of element
    • delete

      boolean delete(K key)
      Deletes entry by specified key
      Parameters:
      key - entry key
      Returns:
      true if successful, or false if entry doesn't exist
    • delete

      long delete(Set<K> keys)
      Deletes entries by specified keys
      Parameters:
      keys - entry keys
      Returns:
      number of deleted elements
    • delete

      long delete(String path, Set<K> keys)
      Deletes JSON elements specified by keys and JSONPath
      Parameters:
      path - JSON path
      keys - entry keys
      Returns:
      number of deleted elements
    • sizeInMemory

      long sizeInMemory(K key)
      Returns size of entry in bytes specified by key.
      Parameters:
      key - entry key
      Returns:
      entry size
    • get

      V get(K key)
      Retrieves value by specified key.
      Parameters:
      key - entry key
      Returns:
      element
    • get

      Map<K,V> get(Set<K> keys)
      Retrieves values by specified keys.
      Parameters:
      keys - entry keys
      Returns:
      map with entries where value mapped by key
    • get

      Map<K,V> get(String path, Set<K> keys)
      Retrieves values by specified keys and JSONPath.
      Parameters:
      path - JSON path
      keys - entry keys
      Returns:
      map with entries where value mapped by key
    • getAndDelete

      V getAndDelete(K key)
      Retrieves entry value by specified key and removes it.
      Parameters:
      key - entry key
      Returns:
      element
    • setIfAbsent

      boolean setIfAbsent(K key, V value)
      Sets value only if entry doesn't exist.
      Parameters:
      key - entry key
      value - value to set
      Returns:
      true if successful, or false if element was already set
    • setIfAbsent

      boolean setIfAbsent(K key, V value, Duration duration)
      Sets value with defined duration only if entry doesn't exist.
      Parameters:
      key - entry key
      value - value to set
      duration - expiration duration
      Returns:
      true if successful, or false if element was already set
    • setIfExists

      boolean setIfExists(K key, V value)
      Sets value only if entry already exists.
      Parameters:
      key - entry key
      value - value to set
      Returns:
      true if successful, or false if element wasn't set
    • setIfExists

      boolean setIfExists(K key, V value, Duration duration)
      Sets value with expiration duration only if entry already exists.
      Parameters:
      key - entry key
      value - value to set
      duration - expiration duration
      Returns:
      true if successful, or false if element wasn't set
    • compareAndSet

      boolean compareAndSet(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.
      Parameters:
      key - entry key
      expect - the expected value
      update - the new value
      Returns:
      true if successful; or false if the actual value was not equal to the expected value.
    • getAndSet

      V getAndSet(K key, V newValue)
      Retrieves current value by specified key and replaces it with new value.
      Parameters:
      key - entry key
      newValue - value to set
      Returns:
      previous value
    • getAndSet

      V getAndSet(K key, V value, Duration duration)
      Retrieves current value by specified key and replaces it with value and defines expiration duration.
      Parameters:
      key - entry key
      value - value to set
      duration - expiration duration
      Returns:
      previous value
    • getAndExpire

      V getAndExpire(K key, Duration duration)
      Retrieves current value by specified key and sets an expiration duration for it.

      Requires Redis 6.2.0 and higher.

      Parameters:
      key - entry key
      duration - of object time to live interval
      Returns:
      value
    • getAndExpire

      V getAndExpire(K key, Instant time)
      Retrieves current value by specified key and sets an expiration date for it.

      Requires Redis 6.2.0 and higher.

      Parameters:
      key - entry key
      time - of exact object expiration moment
      Returns:
      value
    • getAndClearExpire

      V getAndClearExpire(K key)
      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

      void set(K key, V value)
      Stores value by specified key.
      Parameters:
      key - entry key
      value - value to set
    • set

      void set(Map<K,V> entries)
      Stores values by specified keys.
      Parameters:
      entries - entries to store
    • set

      void set(String path, Map<K,V> entries)
      Stores values by specified keys and JSONPath.
      Parameters:
      path - JSONPath
      entries - entries to store
    • set

      void set(K key, V value, Duration duration)
      Stores value by specified key with defined expiration duration.
      Parameters:
      key - entry key
      value - value to set
      duration - expiration duration
    • set

      void set(Map<K,V> entries, Duration duration)
      Stores values by specified keys with defined expiration duration.
      Parameters:
      entries - entries to store
      duration - expiration duration
    • setAndKeepTTL

      void setAndKeepTTL(K key, V value)
      Sets value by specified key and keep existing TTL.

      Requires Redis 6.0.0 and higher.

      Parameters:
      value - value to set
    • addListener

      int addListener(ObjectListener listener)
      Adds object event listener
      Specified by:
      addListener in interface RObject
      Parameters:
      listener - object event listener
      Returns:
      listener id
      See Also:
    • remainTimeToLive

      long remainTimeToLive(K key)
      Remaining time to live of map entry associated with a key.
      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

      Set<K> keySet()
      Returns key set of this map. Keys are loaded in batch. Batch size is 10.
      Returns:
      key set
      See Also:
    • keySet

      Set<K> keySet(int count)
      Returns key set of this map. Keys are loaded in batch. Batch size is defined by count param.
      Parameters:
      count - - size of keys batch
      Returns:
      key set
      See Also:
    • keySet

      Set<K> keySet(String pattern, int count)
      Returns key set of this map. If pattern is not null then only keys match this pattern are loaded. Keys are loaded in batch. Batch size is defined by count param.

      Use org.redisson.client.codec.StringCodec for 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
      count - - size of keys batch
      Returns:
      key set
      See Also:
    • keySet

      Set<K> keySet(String pattern)
      Returns key set of this map. If pattern is not null then only keys match this pattern are loaded.

      Use org.redisson.client.codec.StringCodec for 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

      boolean containsKey(Object key)
      Returns true if this map contains map entry mapped by specified key, otherwise false
      Parameters:
      key - - map key
      Returns:
      true if this map contains map entry mapped by specified key, otherwise false
    • readAllKeySet

      Set<K> readAllKeySet()
      Read all keys at once
      Returns:
      keys
    • size

      int size()
      Returns entries amount in store
      Returns:
      entries amount
    • getCountDownLatch

      RCountDownLatch getCountDownLatch(K key)
      Returns RCountDownLatch instance associated with key
      Parameters:
      key - - map key
      Returns:
      countdownlatch
    • getPermitExpirableSemaphore

      RPermitExpirableSemaphore getPermitExpirableSemaphore(K key)
      Returns RPermitExpirableSemaphore instance associated with key
      Parameters:
      key - - map key
      Returns:
      permitExpirableSemaphore
    • getSemaphore

      RSemaphore getSemaphore(K key)
      Returns RSemaphore instance associated with key
      Parameters:
      key - - map key
      Returns:
      semaphore
    • getFairLock

      RLock getFairLock(K key)
      Returns RLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      fairlock
    • getReadWriteLock

      RReadWriteLock getReadWriteLock(K key)
      Returns RReadWriteLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      readWriteLock
    • getLock

      RLock getLock(K key)
      Returns RLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      lock