net.sf.ehcache.store
Class AbstractPolicy
java.lang.Object
net.sf.ehcache.store.AbstractPolicy
- All Implemented Interfaces:
- Policy
- Direct Known Subclasses:
- FifoPolicy, LfuPolicy, LruPolicy
public abstract class AbstractPolicy
- extends Object
- implements Policy
A base policy class
- Author:
- Greg Luck
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractPolicy
public AbstractPolicy()
calculateSampleSize
public static int calculateSampleSize(int populationSize)
- sampleSize how many samples to take
- Parameters:
populationSize
- the size of the store
- Returns:
- the smaller of the map size and the default sample size of 30
selectedBasedOnPolicy
public Element selectedBasedOnPolicy(Element[] sampledElements,
Element justAdded)
- Finds the best eviction candidate based on the sampled elements. What distuingishes this approach
from the classic data structures approach, is that an Element contains metadata which can be used
for making policy decisions, while generic data structures do not.
- Specified by:
selectedBasedOnPolicy
in interface Policy
- Parameters:
sampledElements
- this should be a random subset of the populationjustAdded
- we never want to select the element just added. May be null.
- Returns:
- the least hit
generateRandomSample
public static int[] generateRandomSample(int populationSize)
- Generates a random sample from a population
- Parameters:
populationSize
- the size to draw from
- Returns:
- a list of random offsets
Copyright 2001-2014, Terracotta, Inc.