Class CacheItemImpl

  • All Implemented Interfaces:
    CacheItem

    public class CacheItemImpl
    extends Object
    implements CacheItem
    Default implementation of CacheItem.
    Author:
    Sumer Jabri, Alfonso Vásquez
    • Field Detail

      • scope

        protected final String scope
      • ticksAtCreation

        protected final long ticksAtCreation
      • key

        protected final Object key
      • value

        protected final Object value
      • ticksToExpire

        protected final long ticksToExpire
      • ticksToRefresh

        protected final long ticksToRefresh
      • loaderParams

        protected final Object[] loaderParams
    • Constructor Detail

      • CacheItemImpl

        public CacheItemImpl​(String scope,
                             long ticksAtCreation,
                             Object key,
                             Object value,
                             long ticksToExpire,
                             long ticksToRefresh,
                             CacheLoader loader,
                             Object[] loaderParams)
        Value constructor.
    • Method Detail

      • getKey

        public Object getKey()
        Returns the item's key, used to identify the item within the cache.
        Specified by:
        getKey in interface CacheItem
      • getTicksAtCreation

        public long getTicksAtCreation()
        Returns the number of ticks that had passed at the moment the item was created.
        Specified by:
        getTicksAtCreation in interface CacheItem
      • getTicksToExpire

        public long getTicksToExpire()
        Returns the number of ticks that are required for the item to expire.
        Specified by:
        getTicksToExpire in interface CacheItem
      • getTicksToRefresh

        public long getTicksToRefresh()
        Returns the number of ticks the are required for the item to be refreshed.
        Specified by:
        getTicksToRefresh in interface CacheItem
      • isExpired

        public boolean isExpired​(long currentTicks)
        Returns true if the item has expired according to the number of ticks specified.
        Specified by:
        isExpired in interface CacheItem
        Parameters:
        currentTicks - the current number of ticks
        Returns:
        true if the item has expired according to the number of ticks specified, false otherwise
      • needsRefresh

        public boolean needsRefresh​(long currentTicks)
        Returns true if the item needs to be refreshed according to the number of ticks specified.
        Specified by:
        needsRefresh in interface CacheItem
        Parameters:
        currentTicks - the current number of ticks
        Returns:
        true if the item needs to be refreshed according to the number of ticks specified, false otherwise
      • equals

        public boolean equals​(Object o)
        Returns true if the specified CacheItemImpl's and this instance's key and scope are equal.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object