本文整理汇总了Java中com.espertech.esper.client.ConfigurationCacheReferenceType类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationCacheReferenceType类的具体用法?Java ConfigurationCacheReferenceType怎么用?Java ConfigurationCacheReferenceType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationCacheReferenceType类属于com.espertech.esper.client包,在下文中一共展示了ConfigurationCacheReferenceType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DataCacheExpiringImpl
import com.espertech.esper.client.ConfigurationCacheReferenceType; //导入依赖的package包/类
/**
* Ctor.
*
* @param maxAgeSec is the maximum age in seconds
* @param purgeIntervalSec is the purge interval in seconds
* @param cacheReferenceType indicates whether hard, soft or weak references are used in the cache
* @param schedulingService is a service for call backs at a scheduled time, for purging
* @param scheduleSlot slot for scheduling callbacks for this cache
* @param epStatementAgentInstanceHandle is the statements-own handle for use in registering callbacks with services
* @param timeAbacus time abacus
*/
public DataCacheExpiringImpl(double maxAgeSec,
double purgeIntervalSec,
ConfigurationCacheReferenceType cacheReferenceType,
SchedulingService schedulingService,
long scheduleSlot,
EPStatementAgentInstanceHandle epStatementAgentInstanceHandle,
TimeAbacus timeAbacus) {
this.maxAgeSec = maxAgeSec;
this.purgeIntervalSec = purgeIntervalSec;
this.schedulingService = schedulingService;
this.scheduleSlot = scheduleSlot;
this.timeAbacus = timeAbacus;
if (cacheReferenceType == ConfigurationCacheReferenceType.HARD) {
this.cache = new HashMap<Object, Item>();
} else if (cacheReferenceType == ConfigurationCacheReferenceType.SOFT) {
this.cache = new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT);
} else {
this.cache = new WeakHashMap<Object, Item>();
}
this.epStatementAgentInstanceHandle = epStatementAgentInstanceHandle;
}
示例2: testPurgeInterval
import com.espertech.esper.client.ConfigurationCacheReferenceType; //导入依赖的package包/类
public void testPurgeInterval() {
SchedulingServiceImpl scheduler = new SchedulingServiceImpl(new TimeSourceServiceImpl());
cache = new DataCacheExpiringImpl(10, 20, ConfigurationCacheReferenceType.HARD, scheduler, 1, null, TimeAbacusMilliseconds.INSTANCE); // age 10 sec, purge 1000 seconds
// test single entry in cache
scheduler.setTime(5000);
cache.put(make("a"), 1, new EventTable[]{lists[0]}); // a at 5 sec
assertSame(lists[0], cache.getCached(make("a"), 1)[0]);
scheduler.setTime(26000);
SupportSchedulingServiceImpl.evaluateSchedule(scheduler);
assertEquals(0, cache.getSize());
// test 4 entries in cache
scheduler.setTime(30000);
cache.put(make("b"), 1, new EventTable[]{lists[1]}); // b at 30 sec
scheduler.setTime(35000);
cache.put(make("c"), 1, new EventTable[]{lists[2]}); // c at 35 sec
scheduler.setTime(40000);
cache.put(make("d"), 1, new EventTable[]{lists[3]}); // d at 40 sec
scheduler.setTime(45000);
cache.put(make("e"), 1, new EventTable[]{lists[4]}); // d at 40 sec
scheduler.setTime(50000);
SupportSchedulingServiceImpl.evaluateSchedule(scheduler);
assertEquals(2, cache.getSize()); // only d and e
assertSame(lists[3], cache.getCached(make("d"), 1)[0]);
assertSame(lists[4], cache.getCached(make("e"), 1)[0]);
}
示例3: DataCacheExpiringImpl
import com.espertech.esper.client.ConfigurationCacheReferenceType; //导入依赖的package包/类
/**
* Ctor.
* @param maxAgeSec is the maximum age in seconds
* @param purgeIntervalSec is the purge interval in seconds
* @param cacheReferenceType indicates whether hard, soft or weak references are used in the cache
* @param schedulingService is a service for call backs at a scheduled time, for purging
* @param scheduleSlot slot for scheduling callbacks for this cache
* @param epStatementAgentInstanceHandle is the statements-own handle for use in registering callbacks with services
*/
public DataCacheExpiringImpl(double maxAgeSec,
double purgeIntervalSec,
ConfigurationCacheReferenceType cacheReferenceType,
SchedulingService schedulingService,
ScheduleSlot scheduleSlot,
EPStatementAgentInstanceHandle epStatementAgentInstanceHandle)
{
this.maxAgeMSec = (long) maxAgeSec * 1000;
this.purgeIntervalMSec = (long) purgeIntervalSec * 1000;
this.schedulingService = schedulingService;
this.scheduleSlot = scheduleSlot;
if (cacheReferenceType == ConfigurationCacheReferenceType.HARD)
{
this.cache = new HashMap<Object, Item>();
}
else if (cacheReferenceType == ConfigurationCacheReferenceType.SOFT)
{
this.cache = new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT);
}
else
{
this.cache = new WeakHashMap<Object, Item>();
}
this.epStatementAgentInstanceHandle = epStatementAgentInstanceHandle;
}
示例4: testPurgeInterval
import com.espertech.esper.client.ConfigurationCacheReferenceType; //导入依赖的package包/类
public void testPurgeInterval()
{
SchedulingServiceImpl scheduler = new SchedulingServiceImpl(new TimeSourceServiceImpl());
cache = new DataCacheExpiringImpl(10, 20, ConfigurationCacheReferenceType.HARD, scheduler, new ScheduleSlot(1, 2), null); // age 10 sec, purge 1000 seconds
// test single entry in cache
scheduler.setTime(5000);
cache.put(make("a"), lists[0]); // a at 5 sec
assertSame(lists[0], cache.getCached(make("a")));
scheduler.setTime(26000);
SupportSchedulingServiceImpl.evaluateSchedule(scheduler);
assertEquals(0, cache.getSize());
// test 4 entries in cache
scheduler.setTime(30000);
cache.put(make("b"), lists[1]); // b at 30 sec
scheduler.setTime(35000);
cache.put(make("c"), lists[2]); // c at 35 sec
scheduler.setTime(40000);
cache.put(make("d"), lists[3]); // d at 40 sec
scheduler.setTime(45000);
cache.put(make("e"), lists[4]); // d at 40 sec
scheduler.setTime(50000);
SupportSchedulingServiceImpl.evaluateSchedule(scheduler);
assertEquals(2, cache.getSize()); // only d and e
assertSame(lists[3], cache.getCached(make("d")));
assertSame(lists[4], cache.getCached(make("e")));
}
示例5: testGet
import com.espertech.esper.client.ConfigurationCacheReferenceType; //导入依赖的package包/类
public void testGet() {
scheduler = new SupportSchedulingServiceImpl();
cache = new DataCacheExpiringImpl(10, 1000, ConfigurationCacheReferenceType.HARD, scheduler, 1, null, TimeAbacusMilliseconds.INSTANCE); // age 10 sec, purge 1000 seconds
assertNull(cache.getCached(make("a"), 1));
scheduler.setTime(5000);
cache.put(make("a"), 1, new EventTable[]{lists[0]}); // a at 5 sec
assertSame(lists[0], cache.getCached(make("a"), 1)[0]);
scheduler.setTime(10000);
cache.put(make("b"), 1, new EventTable[]{lists[1]}); // b at 10 sec
assertSame(lists[0], cache.getCached(make("a"), 1)[0]);
assertSame(lists[1], cache.getCached(make("b"), 1)[0]);
scheduler.setTime(11000);
cache.put(make("c"), 1, new EventTable[]{lists[2]}); // c at 11 sec
cache.put(make("d"), 1, new EventTable[]{lists[3]}); // d at 11 sec
scheduler.setTime(14999);
assertSame(lists[0], cache.getCached(make("a"), 1)[0]);
scheduler.setTime(15000);
assertSame(lists[0], cache.getCached(make("a"), 1)[0]);
scheduler.setTime(15001);
assertNull(cache.getCached(make("a"), 1));
scheduler.setTime(15001);
assertNull(cache.getCached(make("a"), 1));
scheduler.setTime(15001);
assertNull(cache.getCached(make("a"), 1));
assertSame(lists[1], cache.getCached(make("b"), 1)[0]);
assertSame(lists[2], cache.getCached(make("c"), 1)[0]);
assertSame(lists[3], cache.getCached(make("d"), 1)[0]);
scheduler.setTime(20000);
assertSame(lists[1], cache.getCached(make("b"), 1)[0]);
scheduler.setTime(20001);
assertNull(cache.getCached(make("b"), 1));
scheduler.setTime(21001);
assertNull(cache.getCached(make("a"), 1));
assertNull(cache.getCached(make("b"), 1));
assertNull(cache.getCached(make("c"), 1));
assertNull(cache.getCached(make("d"), 1));
scheduler.setTime(22000);
cache.put(make("b"), 1, new EventTable[]{lists[1]}); // b at 22 sec
cache.put(make("d"), 1, new EventTable[]{lists[3]}); // d at 22 sec
scheduler.setTime(32000);
assertSame(lists[1], cache.getCached(make("b"), 1)[0]);
assertSame(lists[3], cache.getCached(make("d"), 1)[0]);
}
示例6: testGet
import com.espertech.esper.client.ConfigurationCacheReferenceType; //导入依赖的package包/类
public void testGet()
{
scheduler = new SupportSchedulingServiceImpl();
cache = new DataCacheExpiringImpl(10, 1000, ConfigurationCacheReferenceType.HARD, scheduler, null, null); // age 10 sec, purge 1000 seconds
assertNull(cache.getCached(make("a")));
scheduler.setTime(5000);
cache.put(make("a"), lists[0]); // a at 5 sec
assertSame(lists[0], cache.getCached(make("a")));
scheduler.setTime(10000);
cache.put(make("b"), lists[1]); // b at 10 sec
assertSame(lists[0], cache.getCached(make("a")));
assertSame(lists[1], cache.getCached(make("b")));
scheduler.setTime(11000);
cache.put(make("c"), lists[2]); // c at 11 sec
cache.put(make("d"), lists[3]); // d at 11 sec
scheduler.setTime(14999);
assertSame(lists[0], cache.getCached(make("a")));
scheduler.setTime(15000);
assertSame(lists[0], cache.getCached(make("a")));
scheduler.setTime(15001);
assertNull(cache.getCached(make("a")));
scheduler.setTime(15001);
assertNull(cache.getCached(make("a")));
scheduler.setTime(15001);
assertNull(cache.getCached(make("a")));
assertSame(lists[1], cache.getCached(make("b")));
assertSame(lists[2], cache.getCached(make("c")));
assertSame(lists[3], cache.getCached(make("d")));
scheduler.setTime(20000);
assertSame(lists[1], cache.getCached(make("b")));
scheduler.setTime(20001);
assertNull(cache.getCached(make("b")));
scheduler.setTime(21001);
assertNull(cache.getCached(make("a")));
assertNull(cache.getCached(make("b")));
assertNull(cache.getCached(make("c")));
assertNull(cache.getCached(make("d")));
scheduler.setTime(22000);
cache.put(make("b"), lists[1]); // b at 22 sec
cache.put(make("d"), lists[3]); // d at 22 sec
scheduler.setTime(32000);
assertSame(lists[1], cache.getCached(make("b")));
assertSame(lists[3], cache.getCached(make("d")));
}