Package org.craftercms.core.cache.impl
Class CacheItemImpl
- java.lang.Object
-
- org.craftercms.core.cache.impl.CacheItemImpl
-
-
Field Summary
Fields Modifier and Type Field Description protected Objectkeyprotected CacheLoaderloaderprotected Object[]loaderParamsprotected Stringscopeprotected longticksAtCreationprotected longticksToExpireprotected longticksToRefreshprotected Objectvalue-
Fields inherited from interface org.craftercms.core.cache.CacheItem
NEVER_EXPIRE, NEVER_REFRESH
-
-
Constructor Summary
Constructors Constructor Description CacheItemImpl(String scope, long ticksAtCreation, Object key, Object value, long ticksToExpire, long ticksToRefresh, CacheLoader loader, Object[] loaderParams)Value constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Returns true if the specifiedCacheItemImpl's and this instance's key and scope are equal.ObjectgetKey()Returns the item's key, used to identify the item within the cache.CacheLoadergetLoader()Returns theCacheLoaderused to refresh this item.Object[]getLoaderParams()Returns the additional parameters required by theCacheLoader.load(Object...)method.StringgetScope()Returns the item's scope.longgetTicksAtCreation()Returns the number of ticks that had passed at the moment the item was created.longgetTicksToExpire()Returns the number of ticks that are required for the item to expire.longgetTicksToRefresh()Returns the number of ticks the are required for the item to be refreshed.ObjectgetValue()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.StringtoString()
-
-
-
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
-
loader
protected final CacheLoader loader
-
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
-
getScope
public String getScope()
Returns the item's scope.
-
getKey
public Object getKey()
Returns the item's key, used to identify the item within the cache.
-
getValue
public Object 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
public CacheLoader getLoader()
Returns theCacheLoaderused to refresh this item.
-
getLoaderParams
public Object[] 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
public boolean equals(Object o)
Returns true if the specifiedCacheItemImpl's and this instance's key and scope are equal.
-
-