Package org.craftercms.core.cache
Interface CacheItem
- All Known Implementing Classes:
CacheItemImpl
public interface CacheItem
Provides information about an item residing in the cache.
- Author:
- Sumer Jabri, Alfonso Vásquez
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Indicates that an item should never expire.static final long
Indicates that an item should never refresh. -
Method Summary
Modifier and TypeMethodDescriptiongetKey()
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.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.
-
Field Details
-
NEVER_EXPIRE
static final long NEVER_EXPIREIndicates that an item should never expire.- See Also:
-
NEVER_REFRESH
static final long NEVER_REFRESHIndicates that an item should never refresh.- See Also:
-
-
Method Details
-
getScope
String getScope()Returns the item's scope. -
getKey
Object getKey()Returns the item's key, used to identify the item within the cache. -
getValue
Object getValue()Returns the item's value. -
getTicksAtCreation
long getTicksAtCreation()Returns the number of ticks that had passed at the moment the item was created. -
getTicksToExpire
long getTicksToExpire()Returns the number of ticks that are required for the item to expire. -
getTicksToRefresh
long getTicksToRefresh()Returns the number of ticks the are required for the item to be refreshed. -
getLoader
CacheLoader getLoader()Returns theCacheLoader
used to refresh this item. -
getLoaderParams
Object[] getLoaderParams()Returns the additional parameters required by theCacheLoader.load(Object...)
method. -
isExpired
boolean isExpired(long currentTicks) Returns true if the item has expired according to the number of ticks specified.- Parameters:
currentTicks
- the current number of ticks- Returns:
- true if the item has expired according to the number of ticks specified, false otherwise
-
needsRefresh
boolean needsRefresh(long currentTicks) Returns true if the item needs to be refreshed according to the number of ticks specified.- 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
-