*/
private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
throws ExoCacheInitException
{
final Configuration configuration = cache.getConfiguration();
final MRUAlgorithmConfig mru = new MRUAlgorithmConfig(maxNodes);
mru.setMinTimeToLive(minTimeToLive);
// Create an eviction region config
final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, mru);
final EvictionConfig evictionConfig = configuration.getEvictionConfig();
evictionConfig.setDefaultEvictionRegionConfig(erc);
return new AbstractExoCache<Serializable, Object>(config, cache)
{
public void setMaxSize(int max)
{
mru.setMaxNodes(max);
}
public void setLiveTime(long period)
{
mru.setMinTimeToLive(period);
}
@ManagedName("MaxNodes")
@ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
public int getMaxSize()
{
return mru.getMaxNodes();
}
@ManagedName("MinTimeToLive")
@ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
public long getLiveTime()
{
return mru.getMinTimeToLive();
}
};
}