Class CacheItemImpl

java.lang.Object
org.craftercms.core.cache.impl.CacheItemImpl
All Implemented Interfaces:
CacheItem

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

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

      protected final CacheLoader loader
    • loaderParams

      protected final Object[] loaderParams
  • Constructor Details

    • CacheItemImpl

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

    • getScope

      public String getScope()
      Returns the item's scope.
      Specified by:
      getScope in interface CacheItem
    • getKey

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

      public Object getValue()
      Returns the item's value.
      Specified by:
      getValue 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
    • getLoader

      public CacheLoader getLoader()
      Returns the CacheLoader used to refresh this item.
      Specified by:
      getLoader in interface CacheItem
    • getLoaderParams

      public Object[] getLoaderParams()
      Returns the additional parameters required by the CacheLoader.load(Object...) method.
      Specified by:
      getLoaderParams 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
    • toString

      public String toString()
      Overrides:
      toString in class Object