Class SizeStrategy

  • All Implemented Interfaces:
    CloudCacheStrategy

    public class SizeStrategy
    extends java.lang.Object
    implements CloudCacheStrategy
    This strategy maintains the size of the internal storage.
    Author:
    javaito
    • Constructor Summary

      Constructors 
      Constructor Description
      SizeStrategy​(java.lang.Integer size)  
    • Method Summary

      Modifier and Type Method Description
      java.util.Set<java.lang.Object> applyStrategy()
      This method must evaluate the specific strategy and return all the ids that will be removed of the cache implementation.
      void init​(CloudCache cacheInstance)
      This method initialize the distributed map to maintains the size of the cache.
      void onAdd​(java.lang.Object id, java.lang.Object value)
      Add a new id into the internal collection.
      void onRemove​(java.lang.Object id)
      Remove a specific id of the internal collection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SizeStrategy

        public SizeStrategy​(java.lang.Integer size)
    • Method Detail

      • init

        public void init​(CloudCache cacheInstance)
        This method initialize the distributed map to maintains the size of the cache.
        Specified by:
        init in interface CloudCacheStrategy
        Parameters:
        cacheInstance - Instance of cache.
      • onRemove

        public void onRemove​(java.lang.Object id)
        Remove a specific id of the internal collection.
        Specified by:
        onRemove in interface CloudCacheStrategy
        Parameters:
        id - Id removed to the cache instance.
      • onAdd

        public void onAdd​(java.lang.Object id,
                          java.lang.Object value)
        Add a new id into the internal collection.
        Specified by:
        onAdd in interface CloudCacheStrategy
        Parameters:
        id - Id added into the cache instance.
        value - Value added into cache.
      • applyStrategy

        public java.util.Set<java.lang.Object> applyStrategy()
        This method must evaluate the specific strategy and return all the ids that will be removed of the cache implementation.
        Specified by:
        applyStrategy in interface CloudCacheStrategy
        Returns:
        Collection of the ids that will be removed.