Interface ExoCache<K extends Serializable,​V>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void addCacheListener​(CacheListener<? super K,​? super V> listener)
      Add a listener.
      void clearCache()
      Clears the cache.
      V get​(Serializable key)
      Performs a lookup operation.
      List<? extends V> getCachedObjects()
      Returns a list of cached object that are considered as valid when the method is called.
      int getCacheHit()
      Returns the number of time the cache was queried and a valid entry was returned.
      int getCacheMiss()
      Returns the number of time the cache was queried and no entry was returned.
      int getCacheSize()
      Returns the number of entries in the cache.
      String getLabel()
      Returns the cache label
      long getLiveTime()
      Returns the maximum life time of an entry in the cache.
      int getMaxSize()
      Returns the maximum capacity of the cache.
      String getName()
      Returns the cache name
      boolean isLogEnabled()  
      default void onClearCache()
      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.
      V remove​(Serializable key)
      Removes an entry from the cache.
      List<? extends V> removeCachedObjects()
      Clears the cache and returns the list of cached object that are considered as valid when the method is called.
      default void removeLocal​(Serializable key)
      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 setLabel​(String s)
      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 setName​(String name)
      Sets the cache name.
    • Method Detail

      • 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
      • 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
      • clearCache

        void clearCache()
        Clears the cache.
      • 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
      • 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)