com.espertech.esper.epl.db
Class DataCacheExpiringImpl

java.lang.Object
  extended by com.espertech.esper.epl.db.DataCacheExpiringImpl
All Implemented Interfaces:
DataCache, ScheduleHandleCallback

public class DataCacheExpiringImpl
extends java.lang.Object
implements DataCache, 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
DataCacheExpiringImpl(double maxAgeSec, double purgeIntervalSec, ConfigurationCacheReferenceType cacheReferenceType, SchedulingService schedulingService, ScheduleSlot scheduleSlot, EPStatementAgentInstanceHandle epStatementAgentInstanceHandle)
          Ctor.
 
Method Summary
 EventTable[] getCached(java.lang.Object[] lookupKeys)
          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  long getMaxAgeMSec()
          Returns the maximum age in milliseconds.
protected  long getPurgeIntervalMSec()
          Returns the purge interval in milliseconds.
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 caching
 void put(java.lang.Object[] lookupKeys, EventTable[] rows)
          Puts into the cache a key and a list of rows, or an empty list if zero rows.
 void scheduledTrigger(ExtensionServicesContext extensionServicesContext)
          Callback that is invoked as indicated by a schedule added to the scheduling service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataCacheExpiringImpl

public DataCacheExpiringImpl(double maxAgeSec,
                             double purgeIntervalSec,
                             ConfigurationCacheReferenceType cacheReferenceType,
                             SchedulingService schedulingService,
                             ScheduleSlot scheduleSlot,
                             EPStatementAgentInstanceHandle epStatementAgentInstanceHandle)
Ctor.

Parameters:
maxAgeSec - is the maximum age in seconds
purgeIntervalSec - is the purge interval in seconds
cacheReferenceType - indicates whether hard, soft or weak references are used in the cache
schedulingService - is a service for call backs at a scheduled time, for purging
scheduleSlot - slot for scheduling callbacks for this cache
epStatementAgentInstanceHandle - is the statements-own handle for use in registering callbacks with services
Method Detail

getCached

public EventTable[] getCached(java.lang.Object[] lookupKeys)
Description copied from interface: DataCache
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 interface DataCache
Parameters:
lookupKeys - 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

public void put(java.lang.Object[] lookupKeys,
                EventTable[] rows)
Description copied from interface: DataCache
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 interface DataCache
Parameters:
lookupKeys - is the keys to the cache entry
rows - is a number of rows

getMaxAgeMSec

protected long getMaxAgeMSec()
Returns the maximum age in milliseconds.

Returns:
millisecon max age

getPurgeIntervalMSec

protected long getPurgeIntervalMSec()
Returns the purge interval in milliseconds.

Returns:
millisecond purge interval

isActive

public boolean isActive()
Description copied from interface: DataCache
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 interface DataCache
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(ExtensionServicesContext extensionServicesContext)
Description copied from interface: ScheduleHandleCallback
Callback that is invoked as indicated by a schedule added to the scheduling service.

Specified by:
scheduledTrigger in interface ScheduleHandleCallback
Parameters:
extensionServicesContext - is a marker interface for providing custom extension services passed to the triggered class

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com