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
Modifier and TypeFieldDescriptionprotected final Object
protected final CacheLoader
protected final Object[]
protected final String
protected final long
protected final long
protected final long
protected final Object
Fields inherited from interface org.craftercms.core.cache.CacheItem
NEVER_EXPIRE, NEVER_REFRESH
-
Constructor Summary
ConstructorDescriptionCacheItemImpl
(String scope, long ticksAtCreation, Object key, Object value, long ticksToExpire, long ticksToRefresh, CacheLoader loader, Object[] loaderParams) Value constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns 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 theCacheLoader
used to refresh this item.Object[]
Returns the additional parameters required by theCacheLoader.load(Object...)
method.getScope()
Returns the item's scope.long
Returns the number of ticks that had passed at the moment the item was created.long
Returns the number of ticks that are required for the item to expire.long
Returns the number of ticks the are required for the item to be refreshed.getValue()
Returns the item's value.int
hashCode()
boolean
isExpired
(long currentTicks) Returns true if the item has expired according to the number of ticks specified.boolean
needsRefresh
(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:
getTicksAtCreation
in interfaceCacheItem
-
getTicksToExpire
public long getTicksToExpire()Returns the number of ticks that are required for the item to expire.- Specified by:
getTicksToExpire
in interfaceCacheItem
-
getTicksToRefresh
public long getTicksToRefresh()Returns the number of ticks the are required for the item to be refreshed.- Specified by:
getTicksToRefresh
in interfaceCacheItem
-
getLoader
Returns theCacheLoader
used to refresh this item. -
getLoaderParams
Returns the additional parameters required by theCacheLoader.load(Object...)
method.- Specified by:
getLoaderParams
in 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:
needsRefresh
in 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
-