Interface ExoCache<K extends Serializable,V>

All Known Implementing Classes:
AsyncInvalidationExoCache, ConcurrentFIFOExoCache, FIFOExoCache, InvalidationExoCache, SimpleExoCache

public interface ExoCache<K extends Serializable,V>
Created by The eXo Platform SAS
A bare cache.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addCacheListener(CacheListener<? super K,? super V> listener)
    Add a listener.
    void
    Clears the cache.
    Performs a lookup operation.
    List<? extends V>
    Returns a list of cached object that are considered as valid when the method is called.
    int
    Returns the number of time the cache was queried and a valid entry was returned.
    int
    Returns the number of time the cache was queried and no entry was returned.
    int
    Returns the number of entries in the cache.
    Returns the cache label
    long
    Returns the maximum life time of an entry in the cache.
    int
    Returns the maximum capacity of the cache.
    Returns the cache name
    boolean
     
    default void
    on clear cache event
    default void
    onExpire(K key, V obj)
    On expire entry event
    default void
    onGet(K key, V obj)
    On get entry event
    default void
    onPut(K key, V obj)
    On put entry event
    default void
    onPutLocal(K key, V obj)
    On put entry event
    default void
    onRemove(K key, V obj)
    On remove entry event
    void
    put(K key, V value)
    Performs a put in the cache.
    default void
    putAsyncMap(Map<? extends K,? extends V> objs)
    Performs a put of all the entries provided by the map argument on asynchronous mode.
    default void
    putLocal(K key, V value)
    Performs a put in the cache local mode (avoid replication).
    void
    putMap(Map<? extends K,? extends V> objs)
    Performs a put of all the entries provided by the map argument.
    Removes an entry from the cache.
    List<? extends V>
    Clears the cache and returns the list of cached object that are considered as valid when the method is called.
    default void
    Removes an entry from the cache local mode (avoid replication).
    void
    select(CachedObjectSelector<? super K,? super V> selector)
    Selects a subset of the cache.
    void
    Sets the cache label
    void
    setLiveTime(long period)
    Sets the maximum life time of an entry in the cache.
    void
    setLogEnabled(boolean b)
     
    void
    setMaxSize(int max)
    Sets the maximum capacity of the cache.
    void
    Sets the cache name.
  • Method Details

    • getName

      String getName()
      Returns the cache name
      Returns:
      the cache name
    • setName

      void setName(String name)
      Sets the cache name.
      Parameters:
      name - the cache name
    • getLabel

      String getLabel()
      Returns the cache label
      Returns:
      the cache label
    • setLabel

      void setLabel(String s)
      Sets the cache label
      Parameters:
      s - the cache label
    • get

      V get(Serializable key)
      Performs a lookup operation.
      Parameters:
      key - the cache key
      Returns:
      the cached value which may be evaluated to null
    • remove

      V remove(Serializable key) throws NullPointerException
      Removes an entry from the cache.
      Parameters:
      key - the cache key
      Returns:
      the previously cached value or null if no entry existed or that entry value was evaluated to null
      Throws:
      NullPointerException - if the provided key is null
    • removeLocal

      default void removeLocal(Serializable key) throws NullPointerException
      Removes an entry from the cache local mode (avoid replication).
      Parameters:
      key - the cache key
      Throws:
      NullPointerException - if the provided key is null
    • put

      void put(K key, V value) throws NullPointerException
      Performs a put in the cache.
      Parameters:
      key - the cache key
      value - the cached value
      Throws:
      NullPointerException - if the key is null
    • putLocal

      default void putLocal(K key, V value) throws NullPointerException
      Performs a put in the cache local mode (avoid replication).
      Parameters:
      key - the cache key
      value - the cached value
      Throws:
      NullPointerException - if the key is null
    • putMap

      void putMap(Map<? extends K,? extends V> objs) throws NullPointerException, IllegalArgumentException
      Performs a put of all the entries provided by the map argument.
      Parameters:
      objs - the objects to put
      Throws:
      NullPointerException - if the provided argument is null
      IllegalArgumentException - if the provided map contains a null key
    • putAsyncMap

      default void putAsyncMap(Map<? extends K,? extends V> objs) throws NullPointerException, IllegalArgumentException
      Performs a put of all the entries provided by the map argument on asynchronous mode.
      Parameters:
      objs - the objects to put
      Throws:
      NullPointerException - if the provided argument is null
      IllegalArgumentException - if the provided map contains a null key
      UnsupportedOperationException - if async put operation is not supported
    • clearCache

      void clearCache()
      Clears the cache.
    • select

      void select(CachedObjectSelector<? super K,? super V> selector) throws Exception
      Selects a subset of the cache.
      Parameters:
      selector - the selector
      Throws:
      Exception - any exception
    • getCacheSize

      int getCacheSize()
      Returns the number of entries in the cache.
      Returns:
      the size of the cache
    • getMaxSize

      int getMaxSize()
      Returns the maximum capacity of the cache.
      Returns:
      the maximum capacity
    • setMaxSize

      void setMaxSize(int max)
      Sets the maximum capacity of the cache.
      Parameters:
      max - the maximum capacity
    • getLiveTime

      long getLiveTime()
      Returns the maximum life time of an entry in the cache. The life time is a value in seconds, a negative value means that the life time is infinite.
      Returns:
      the live time
    • setLiveTime

      void setLiveTime(long period)
      Sets the maximum life time of an entry in the cache.
      Parameters:
      period - the live time
    • getCacheHit

      int getCacheHit()
      Returns the number of time the cache was queried and a valid entry was returned.
      Returns:
      the cache hits
    • getCacheMiss

      int getCacheMiss()
      Returns the number of time the cache was queried and no entry was returned.
      Returns:
      the cache misses
    • getCachedObjects

      List<? extends V> getCachedObjects() throws Exception
      Returns a list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.
      Returns:
      the list of cached objects
      Throws:
      Exception - any exception
    • removeCachedObjects

      List<? extends V> removeCachedObjects()
      Clears the cache and returns the list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.
      Returns:
      the list of cached objects
    • addCacheListener

      void addCacheListener(CacheListener<? super K,? super V> listener) throws NullPointerException
      Add a listener.
      Parameters:
      listener - the listener to add
      Throws:
      NullPointerException - if the listener is null
    • onGet

      default void onGet(K key, V obj)
      On get entry event
      Parameters:
      key - entry key
      obj - value
    • onExpire

      default void onExpire(K key, V obj)
      On expire entry event
      Parameters:
      key - entry key
      obj - value
    • onRemove

      default void onRemove(K key, V obj)
      On remove entry event
      Parameters:
      key - entry key
      obj - value
    • onPut

      default void onPut(K key, V obj)
      On put entry event
      Parameters:
      key - entry key
      obj - value
    • onPutLocal

      default void onPutLocal(K key, V obj)
      On put entry event
      Parameters:
      key - entry key
      obj - value
    • onClearCache

      default void onClearCache()
      on clear cache event
    • isLogEnabled

      boolean isLogEnabled()
    • setLogEnabled

      void setLogEnabled(boolean b)