ehcache

net.sf.ehcache.store
Class LfuPolicy

java.lang.Object
  extended by net.sf.ehcache.store.LfuPolicy

public final class LfuPolicy
extends java.lang.Object

Contains common LFU policy code for use between the LfuMemoryStore and the DiskStore, which also uses an LfuPolicy for evictions.

Version:
$Id: LfuPolicy.java 539 2007-08-15 08:05:59Z gregluck $
Author:
Greg Luck

Nested Class Summary
static interface LfuPolicy.Metadata
          A type representing relevant metadata from an element, used by LfuPolicy for its operations.
 
Method Summary
static int[] generateRandomSample(int populationSize)
          Generates a random sample from a population
static LfuPolicy.Metadata leastHit(LfuPolicy.Metadata[] sampledElements, LfuPolicy.Metadata justAdded)
          Finds the least hit of the sampled elements provided
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

leastHit

public static LfuPolicy.Metadata leastHit(LfuPolicy.Metadata[] sampledElements,
                                          LfuPolicy.Metadata justAdded)
Finds the least hit of the sampled elements provided

Parameters:
sampledElements - this should be a random subset of the population
justAdded - 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

ehcache