Interface SyncCache<K,V>


public interface SyncCache<K,V>
Since:
14.0
  • Method Details

    • name

      String name()
      Returns the name of this cache
      Returns:
      the name of the cache
    • configuration

      CacheConfiguration configuration()
      Returns the configuration of this cache
      Returns:
      the cache configuration
    • container

      SyncContainer container()
      Return the container of this cache
      Returns:
      the cache container
    • get

      default V get(K key)
      Get the value of the Key if such exists
      Parameters:
      key -
      Returns:
      the value
    • get

      default V get(K key, CacheOptions options)
      Get the value of the Key if such exists
      Parameters:
      key -
      Returns:
      the value
    • getEntry

      default CacheEntry<K,V> getEntry(K key)
      Get the entry of the Key if such exists
      Parameters:
      key -
      Returns:
      the entry
    • getEntry

      CacheEntry<K,V> getEntry(K key, CacheOptions options)
      Get the entry of the Key if such exists
      Parameters:
      key -
      options -
      Returns:
      the entry
    • put

      default CacheEntry<K,V> put(K key, V value)
      Insert the key/value pair. Returns the previous value if present.
      Parameters:
      key -
      value -
      Returns:
      Void
    • put

      CacheEntry<K,V> put(K key, V value, CacheWriteOptions options)
      Parameters:
      key -
      value -
      options -
      Returns:
      Void
    • set

      default void set(K key, V value)
      Similar to put(Object, Object) but does not return the previous value.
    • set

      default void set(K key, V value, CacheWriteOptions options)
      Parameters:
      key -
      value -
      options -
    • putIfAbsent

      default CacheEntry<K,V> putIfAbsent(K key, V value)
      Save the key/value.
      Parameters:
      key -
      value -
      Returns:
      the previous value if present
    • putIfAbsent

      CacheEntry<K,V> putIfAbsent(K key, V value, CacheWriteOptions options)
      Insert the key/value if such key does not exist
      Parameters:
      key -
      value -
      options -
      Returns:
      the previous value if present
    • setIfAbsent

      default boolean setIfAbsent(K key, V value)
      Save the key/value.
      Parameters:
      key -
      value -
      Returns:
      true if the entry was set
    • setIfAbsent

      default boolean setIfAbsent(K key, V value, CacheWriteOptions options)
      Insert the key/value if such key does not exist
      Parameters:
      key -
      value -
      options -
      Returns:
      Void
    • replace

      default boolean replace(K key, V value, CacheEntryVersion version)
      Parameters:
      key -
      value -
      Returns:
    • replace

      default boolean replace(K key, V value, CacheEntryVersion version, CacheWriteOptions options)
      Parameters:
      key -
      value -
      options -
      Returns:
    • getOrReplaceEntry

      default CacheEntry<K,V> getOrReplaceEntry(K key, V value, CacheEntryVersion version)
      Parameters:
      key -
      value -
      version -
      Returns:
    • getOrReplaceEntry

      CacheEntry<K,V> getOrReplaceEntry(K key, V value, CacheEntryVersion version, CacheWriteOptions options)
      Parameters:
      key -
      value -
      version -
      options -
      Returns:
    • remove

      default boolean remove(K key)
      Delete the key
      Parameters:
      key -
      Returns:
      true if the entry was removed
    • remove

      default boolean remove(K key, CacheOptions options)
      Delete the key
      Parameters:
      key -
      options -
      Returns:
      true if the entry was removed
    • remove

      default boolean remove(K key, CacheEntryVersion version)
      Delete the key only if the version matches
      Parameters:
      key -
      version -
      Returns:
      whether the entry was removed.
    • remove

      boolean remove(K key, CacheEntryVersion version, CacheOptions options)
      Delete the key only if the version matches
      Parameters:
      key -
      version -
      options -
      Returns:
      whether the entry was removed.
    • getAndRemove

      default CacheEntry<K,V> getAndRemove(K key)
      Removes the key and returns its value if present.
      Parameters:
      key -
      Returns:
      the value of the key before removal. Returns null if the key didn't exist.
    • getAndRemove

      CacheEntry<K,V> getAndRemove(K key, CacheOptions options)
      Removes the key and returns its value if present.
      Parameters:
      key -
      options -
      Returns:
      the value of the key before removal. Returns null if the key didn't exist.
    • keys

      default CloseableIterable<K> keys()
      Retrieve all keys
      Returns:
    • keys

      Retrieve all keys
      Parameters:
      options -
      Returns:
    • entries

      default CloseableIterable<CacheEntry<K,V>> entries()
      Retrieve all entries
      Returns:
    • entries

      Retrieve all entries
      Parameters:
      options -
      Returns:
    • putAll

      default void putAll(Map<K,V> entries)
      Puts all entries
      Parameters:
      entries -
    • putAll

      void putAll(Map<K,V> entries, CacheWriteOptions options)
      Parameters:
      entries -
      options -
    • getAll

      default Map<K,V> getAll(Set<K> keys)
      Retrieves all entries for the supplied keys
      Parameters:
      keys -
      Returns:
    • getAll

      Map<K,V> getAll(Set<K> keys, CacheOptions options)
      Retrieves all entries for the supplied keys
      Parameters:
      keys -
      options -
      Returns:
    • getAll

      default Map<K,V> getAll(K... keys)
      Retrieves all entries for the supplied keys
      Parameters:
      keys -
      Returns:
    • getAll

      Map<K,V> getAll(CacheOptions options, K... keys)
      Retrieves all entries for the supplied keys
      Parameters:
      options -
      keys -
      Returns:
    • removeAll

      default Set<K> removeAll(Set<K> keys)
      Removes a set of keys. Returns the keys that were removed.
      Parameters:
      keys -
      Returns:
    • removeAll

      Set<K> removeAll(Set<K> keys, CacheWriteOptions options)
      Removes a set of keys. Returns the keys that were removed.
      Parameters:
      keys -
      options -
      Returns:
    • getAndRemoveAll

      default Map<K,CacheEntry<K,V>> getAndRemoveAll(Set<K> keys)
      Removes a set of keys. Returns the keys that were removed.
      Parameters:
      keys -
      Returns:
    • getAndRemoveAll

      default Map<K,CacheEntry<K,V>> getAndRemoveAll(Set<K> keys, CacheWriteOptions options)
      Removes a set of keys. Returns the keys that were removed.
      Parameters:
      keys -
      Returns:
    • estimateSize

      default long estimateSize()
      Estimate the size of the store
      Returns:
      Long, estimated size
    • estimateSize

      long estimateSize(CacheOptions options)
      Estimate the size of the store
      Returns:
      Long, estimated size
    • clear

      default void clear()
      Clear the store. If a concurrent operation puts data in the store the clear might not properly work.
    • clear

      void clear(CacheOptions options)
      Clear the store. If a concurrent operation puts data in the store the clear might not properly work.
    • query

      default <R> SyncQuery<K,V,R> query(String query)
      Find by query
      Parameters:
      query -
      Returns:
    • query

      <R> SyncQuery<K,V,R> query(String query, CacheOptions options)
      Find by query
      Type Parameters:
      R -
      Parameters:
      query -
      options -
      Returns:
    • listen

      Listens to the SyncCacheEntryListener
      Parameters:
      listener -
      Returns:
      A AutoCloseable that allows to remove the listener via AutoCloseable.close().
    • process

      default <T> Set<CacheEntryProcessorResult<K,T>> process(Set<K> keys, SyncCacheEntryProcessor<K,V,T> processor)
      Process entries using the supplied processor
      Type Parameters:
      T -
      Parameters:
      keys -
      processor -
    • process

      <T> Set<CacheEntryProcessorResult<K,T>> process(Set<K> keys, SyncCacheEntryProcessor<K,V,T> processor, CacheProcessorOptions options)
      Process entries using the supplied processor
      Type Parameters:
      T -
      Parameters:
      keys -
      processor -
      options -
    • processAll

      default <T> Set<CacheEntryProcessorResult<K,T>> processAll(SyncCacheEntryProcessor<K,V,T> processor)
      Process entries using the supplied processor
      Type Parameters:
      T -
      Parameters:
      processor -
    • processAll

      <T> Set<CacheEntryProcessorResult<K,T>> processAll(SyncCacheEntryProcessor<K,V,T> processor, CacheProcessorOptions options)
      Process entries using the supplied processor
      Type Parameters:
      T -
      Parameters:
      processor -
      options -
    • streaming

      SyncStreamingCache<K> streaming()
      Returns: