Class HistoricalDataCacheExpiringImpl
java.lang.Object
com.espertech.esper.common.internal.epl.historical.datacache.HistoricalDataCacheExpiringImpl
- All Implemented Interfaces:
HistoricalDataCache
,ScheduleHandleCallback
public class HistoricalDataCacheExpiringImpl
extends Object
implements HistoricalDataCache, ScheduleHandleCallback
Implements an expiry-time cache that evicts data when data becomes stale
after a given number of seconds.
The cache reference type indicates which backing Map is used: Weak type uses the WeakHashMap, Soft type uses the apache commons ReferenceMap, and Hard type simply uses a HashMap.
-
Constructor Summary
ConstructorDescriptionHistoricalDataCacheExpiringImpl
(double maxAgeSec, double purgeIntervalSec, CacheReferenceType cacheReferenceType, AgentInstanceContext agentInstanceContext, long scheduleSlot) Ctor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Ask the cache if the keyed value is cached, returning a list or rows if the key is in the cache, or returning null to indicate no such key cached.protected double
Returns the maximum age in milliseconds.double
protected long
getSize()
Returns the current cache size.boolean
isActive()
Returns true if the cache is active and currently caching, or false if the cache is inactive and not currently cachingvoid
put
(Object methodParams, EventTable[] rows) Puts into the cache a key and a list of rows, or an empty list if zero rows.void
Callback that is invoked as indicated by a schedule added to the scheduling service.
-
Constructor Details
-
HistoricalDataCacheExpiringImpl
public HistoricalDataCacheExpiringImpl(double maxAgeSec, double purgeIntervalSec, CacheReferenceType cacheReferenceType, AgentInstanceContext agentInstanceContext, long scheduleSlot) Ctor.- Parameters:
maxAgeSec
- is the maximum age in secondspurgeIntervalSec
- is the purge interval in secondscacheReferenceType
- indicates whether hard, soft or weak references are used in the cacheagentInstanceContext
- agent instance contextscheduleSlot
- slot for scheduling callbacks for this cache
-
-
Method Details
-
getCached
Description copied from interface:HistoricalDataCache
Ask the cache if the keyed value is cached, returning a list or rows if the key is in the cache, or returning null to indicate no such key cached. Zero rows may also be cached.- Specified by:
getCached
in interfaceHistoricalDataCache
- Parameters:
methodParams
- is the keys to look up in the cache- Returns:
- a list of rows that can be empty is the key was found in the cache, or null if the key is not found in the cache
-
put
Description copied from interface:HistoricalDataCache
Puts into the cache a key and a list of rows, or an empty list if zero rows.The put method is designed to be called when the cache does not contain a key as determined by the get method. Implementations typically simply overwrite any keys put into the cache that already existed in the cache.
- Specified by:
put
in interfaceHistoricalDataCache
- Parameters:
methodParams
- is the keys to the cache entryrows
- is a number of rows
-
getMaxAgeSec
protected double getMaxAgeSec()Returns the maximum age in milliseconds.- Returns:
- millisecon max age
-
getPurgeIntervalSec
public double getPurgeIntervalSec() -
isActive
public boolean isActive()Description copied from interface:HistoricalDataCache
Returns true if the cache is active and currently caching, or false if the cache is inactive and not currently caching- Specified by:
isActive
in interfaceHistoricalDataCache
- Returns:
- true for caching enabled, false for no caching taking place
-
getSize
protected long getSize()Returns the current cache size.- Returns:
- cache size
-
scheduledTrigger
public void scheduledTrigger()Description copied from interface:ScheduleHandleCallback
Callback that is invoked as indicated by a schedule added to the scheduling service.- Specified by:
scheduledTrigger
in interfaceScheduleHandleCallback
-
destroy
public void destroy()- Specified by:
destroy
in interfaceHistoricalDataCache
-