Package org.craftercms.core.cache.impl
Class CacheItemImpl
java.lang.Object
org.craftercms.core.cache.impl.CacheItemImpl
- All Implemented Interfaces:
CacheItem
Default implementation of
CacheItem.- Author:
- Sumer Jabri, Alfonso Vásquez
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Objectprotected final CacheLoaderprotected final Object[]protected final Stringprotected final longprotected final longprotected final longprotected final ObjectFields inherited from interface org.craftercms.core.cache.CacheItem
NEVER_EXPIRE, NEVER_REFRESH -
Constructor Summary
ConstructorsConstructorDescriptionCacheItemImpl(String scope, long ticksAtCreation, Object key, Object value, long ticksToExpire, long ticksToRefresh, CacheLoader loader, Object[] loaderParams) Value constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the specifiedCacheItemImpl's and this instance's key and scope are equal.getKey()Returns the item's key, used to identify the item within the cache.Returns theCacheLoaderused to refresh this item.Object[]Returns the additional parameters required by theCacheLoader.load(Object...)method.getScope()Returns the item's scope.longReturns the number of ticks that had passed at the moment the item was created.longReturns the number of ticks that are required for the item to expire.longReturns the number of ticks the are required for the item to be refreshed.getValue()Returns the item's value.inthashCode()booleanisExpired(long currentTicks) Returns true if the item has expired according to the number of ticks specified.booleanneedsRefresh(long currentTicks) Returns true if the item needs to be refreshed according to the number of ticks specified.toString()
-
Field Details
-
scope
-
ticksAtCreation
protected final long ticksAtCreation -
key
-
value
-
ticksToExpire
protected final long ticksToExpire -
ticksToRefresh
protected final long ticksToRefresh -
loader
-
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
Returns the item's scope. -
getKey
Returns the item's key, used to identify the item within the cache. -
getValue
Returns the item's value. -
getTicksAtCreation
public long getTicksAtCreation()Returns the number of ticks that had passed at the moment the item was created.- Specified by:
getTicksAtCreationin interfaceCacheItem
-
getTicksToExpire
public long getTicksToExpire()Returns the number of ticks that are required for the item to expire.- Specified by:
getTicksToExpirein interfaceCacheItem
-
getTicksToRefresh
public long getTicksToRefresh()Returns the number of ticks the are required for the item to be refreshed.- Specified by:
getTicksToRefreshin interfaceCacheItem
-
getLoader
Returns theCacheLoaderused to refresh this item. -
getLoaderParams
Returns the additional parameters required by theCacheLoader.load(Object...)method.- Specified by:
getLoaderParamsin interfaceCacheItem
-
isExpired
public boolean isExpired(long currentTicks) Returns true if the item has expired according to the number of ticks specified. -
needsRefresh
public boolean needsRefresh(long currentTicks) Returns true if the item needs to be refreshed according to the number of ticks specified.- Specified by:
needsRefreshin interfaceCacheItem- 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
Returns true if the specifiedCacheItemImpl's and this instance's key and scope are equal. -
hashCode
public int hashCode() -
toString
-