Interface CacheRx<K,V>

Type Parameters:
K - key type
V - value type

public interface CacheRx<K,V>
RxJava2 interface for JCache
Author:
Nikita Koksharov
  • Method Summary

    Modifier and Type
    Method
    Description
    io.reactivex.rxjava3.core.Completable
    This method empties the cache's contents, without notifying listeners or CacheWriters.
    io.reactivex.rxjava3.core.Single<Boolean>
    This method returns a Boolean true/false value, depending on whether the CacheRx has a mapping for a key k such that key.equals(k).
    io.reactivex.rxjava3.core.Maybe<V>
    get(K key)
    This method retrieves an entry from the cache.
    io.reactivex.rxjava3.core.Single<Map<K,V>>
    getAll(Set<? extends K> keys)
    This method accepts a set of requested keys and retrieves a collection of entries from the CacheRx, returning them as a Map of the associated values.
    io.reactivex.rxjava3.core.Maybe<V>
    getAndPut(K key, V value)
    This method places the given key and value in the cache.
    io.reactivex.rxjava3.core.Maybe<V>
    This method atomically removes the entry for a key only if it is currently mapped to some value.
    io.reactivex.rxjava3.core.Maybe<V>
    getAndReplace(K key, V value)
    This method atomically replaces a given key's value if and only if the key is currently mapped to a value.
    io.reactivex.rxjava3.core.Completable
    put(K key, V value)
    This method places the given value V in the cache and associates it with the given key K.
    io.reactivex.rxjava3.core.Completable
    putAll(Map<? extends K,? extends V> map)
    This method copies all of the entries from the given Map to the CacheRx.
    io.reactivex.rxjava3.core.Single<Boolean>
    putIfAbsent(K key, V value)
    This method places the given key and value in the cache atomically, if the key is not already associated with a value in the cache.
    io.reactivex.rxjava3.core.Single<Boolean>
    remove(K key)
    This method deletes the mapping for a given key from the cache, if it is present.
    io.reactivex.rxjava3.core.Single<Boolean>
    remove(K key, V oldValue)
    This method atomically removes a key's mapping only if it is currently mapped to the provided value.
    io.reactivex.rxjava3.core.Completable
    removeAll(Set<? extends K> keys)
    This method deletes the entries for the given keys.
    io.reactivex.rxjava3.core.Single<Boolean>
    replace(K key, V value)
    This method atomically replaces an entry only if the key is currently mapped to some value.
    io.reactivex.rxjava3.core.Single<Boolean>
    replace(K key, V oldValue, V newValue)
    This method atomically replaces an entry only if the key is currently mapped to a given value.
  • Method Details

    • get

      io.reactivex.rxjava3.core.Maybe<V> get(K key)
      This method retrieves an entry from the cache. If the cache uses the read-through pattern, and the method would return null because the entry is not present in the cache, then the cache's CacheLoader will try to load the entry.
      Parameters:
      key - the key whose value should be returned
      Returns:
      the element, or null if the entry does not exist.
      Throws:
      IllegalStateException - if the cache is in a closed state
      NullPointerException - if the key is null
      javax.cache.CacheException - if there is a problem retrieving the entry from the cache
    • getAll

      io.reactivex.rxjava3.core.Single<Map<K,V>> getAll(Set<? extends K> keys)
      This method accepts a set of requested keys and retrieves a collection of entries from the CacheRx, returning them as a Map of the associated values. If the cache uses the read-through pattern, and the method would return null for a key because an entry is not present in the cache, the Cache's CacheLoader will try to load the entry. If a key's entry cannot be loaded, the key will not appear in the Map.
      Parameters:
      keys - The keys whose values should be returned.
      Returns:
      A Map of entries associated with the given keys. If a key is not found in the cache, it will not be in the Map.
      Throws:
      NullPointerException - if keys is null or contains a null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem retrieving the entries from the cache
    • containsKey

      io.reactivex.rxjava3.core.Single<Boolean> containsKey(K key)
      This method returns a Boolean true/false value, depending on whether the CacheRx has a mapping for a key k such that key.equals(k).
      Parameters:
      key - the key with a possible mapping in the cache.
      Returns:
      true if such a mapping exists
      Throws:
      NullPointerException - if key is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • put

      io.reactivex.rxjava3.core.Completable put(K key, V value)
      This method places the given value V in the cache and associates it with the given key K. If the CacheRx already has a mapping for the key, the previous value is replaced by the given value V. This occurs if and only if c.containsKey(k) would return true.)
      Parameters:
      key - the key to place in the cache
      value - the value to associate with the given key
      Returns:
      void
      Throws:
      NullPointerException - if the key or value is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • getAndPut

      io.reactivex.rxjava3.core.Maybe<V> getAndPut(K key, V value)
      This method places the given key and value in the cache. Any value already in the cache is returned and replaced by the new given value. This occurs if and only if c.containsKey(k) would return true.) If there was no value already in the cache, the method returns null.
      Parameters:
      key - the key to place in the cache
      value - the value to associate with the given key
      Returns:
      the previous value in the cache, or null if none already existed
      Throws:
      NullPointerException - if the key or value is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • putAll

      io.reactivex.rxjava3.core.Completable putAll(Map<? extends K,? extends V> map)
      This method copies all of the entries from the given Map to the CacheRx. This method is equivalent to calling put(k, v) on this cache one time for each mapping from key k to value v in the given Map. Individual puts may occur in any order. If entries in the cache corresponding to entries in the Map, or the Map itself, is changed or removed during this operation, then the behavior of this method is not defined. If default consistency mode is enabled, then each put is atomic but not the entire putAll operation. Listeners can observe individual updates.
      Parameters:
      map - the Map that contains the entries to be copied to the cache
      Returns:
      void
      Throws:
      NullPointerException - if the map is null or contains null keys or values.
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache.
    • putIfAbsent

      io.reactivex.rxjava3.core.Single<Boolean> putIfAbsent(K key, V value)
      This method places the given key and value in the cache atomically, if the key is not already associated with a value in the cache.
      Parameters:
      key - the key to place in the cache
      value - the value to associate with the given key
      Returns:
      true if the value was successfully placed in the cache
      Throws:
      NullPointerException - if the key or value is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • remove

      io.reactivex.rxjava3.core.Single<Boolean> remove(K key)
      This method deletes the mapping for a given key from the cache, if it is present. This occurs if and only if there is a mapping from key k to value v such that (key==null ? k==null : key.equals(k)). This method returns true if the removal was successful, or false if there was no such mapping.
      Parameters:
      key - the key whose mapping will be deleted
      Returns:
      returns true if successful, or false if there was no mapping
      Throws:
      NullPointerException - if the key is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • remove

      io.reactivex.rxjava3.core.Single<Boolean> remove(K key, V oldValue)
      This method atomically removes a key's mapping only if it is currently mapped to the provided value.
      Parameters:
      key - the key whose mapping will be deleted
      oldValue - the value that should be mapped to the given key
      Returns:
      returns true if successful, or false if there was no such mapping
      Throws:
      NullPointerException - if the key is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • getAndRemove

      io.reactivex.rxjava3.core.Maybe<V> getAndRemove(K key)
      This method atomically removes the entry for a key only if it is currently mapped to some value.
      Parameters:
      key - the given key
      Returns:
      the value if it existed, or null if it did not
      Throws:
      NullPointerException - if the key is null.
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • replace

      io.reactivex.rxjava3.core.Single<Boolean> replace(K key, V oldValue, V newValue)
      This method atomically replaces an entry only if the key is currently mapped to a given value.
      Parameters:
      key - the key associated with the given oldValue
      oldValue - the value that should be associated with the key
      newValue - the value that will be associated with the key
      Returns:
      true if the value was replaced, or false if not
      Throws:
      NullPointerException - if the key or values are null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • replace

      io.reactivex.rxjava3.core.Single<Boolean> replace(K key, V value)
      This method atomically replaces an entry only if the key is currently mapped to some value.
      Parameters:
      key - the key mapped to the given value
      value - the value mapped to the given key
      Returns:
      true if the value was replaced, or false if not
      Throws:
      NullPointerException - if the key or value is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • getAndReplace

      io.reactivex.rxjava3.core.Maybe<V> getAndReplace(K key, V value)
      This method atomically replaces a given key's value if and only if the key is currently mapped to a value.
      Parameters:
      key - the key associated with the given value
      value - the value associated with the given key
      Returns:
      the previous value mapped to the given key, or null if there was no such mapping.
      Throws:
      NullPointerException - if the key or value is null
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • removeAll

      io.reactivex.rxjava3.core.Completable removeAll(Set<? extends K> keys)
      This method deletes the entries for the given keys. The order in which the individual entries are removed is undefined. For every entry in the key set, the following are called: • any registered CacheEntryRemovedListeners • if the cache is a write-through cache, the CacheWriter If the key set is empty, the CacheWriter is not called.
      Parameters:
      keys - the keys to remove
      Returns:
      void
      Throws:
      NullPointerException - if keys is null or if it contains a null key
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache
    • clear

      io.reactivex.rxjava3.core.Completable clear()
      This method empties the cache's contents, without notifying listeners or CacheWriters.
      Returns:
      void
      Throws:
      IllegalStateException - if the cache is in a closed state
      javax.cache.CacheException - if there is a problem with the cache