ehcache

net.sf.ehcache.pool.impl
Class AbstractBalancedAccessEvictor<T>

java.lang.Object
  extended by net.sf.ehcache.pool.impl.AbstractBalancedAccessEvictor<T>
Type Parameters:
T - type of store handled by this evictor
All Implemented Interfaces:
PoolEvictor<T>
Direct Known Subclasses:
BalancedAccessOnDiskPoolEvictor, BalancedAccessOnHeapPoolEvictor

public abstract class AbstractBalancedAccessEvictor<T>
extends Object
implements PoolEvictor<T>

Abstract implementation of a global 'cache value' maximizing pool eviction algorithm.

Author:
Chris Dennis

Constructor Summary
AbstractBalancedAccessEvictor()
           
 
Method Summary
protected abstract  long byteSize(T store)
          Return the size in bytes of the supplied store.
protected abstract  long countSize(T store)
          Return the number of mappings in the supplied store.
protected abstract  boolean evict(T store, int count, long bytes)
          Evict the specified number of bytes or the hinted number of elements from the specified store
 boolean freeSpace(Collection<T> from, long bytes)
          Free at least N bytes from a collection of resources
protected abstract  float hitRate(T store)
          Return the hit rate for the supplied store.
protected abstract  float missRate(T store)
          Return the miss rate for the supplied store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBalancedAccessEvictor

public AbstractBalancedAccessEvictor()
Method Detail

evict

protected abstract boolean evict(T store,
                                 int count,
                                 long bytes)
Evict the specified number of bytes or the hinted number of elements from the specified store

Parameters:
store - store to evict from
count - number of elements to evict
bytes - number of bytes to evict
Returns:
true if the eviction succeeded

hitRate

protected abstract float hitRate(T store)
Return the hit rate for the supplied store.

Parameters:
store - store to query
Returns:
hit rate

missRate

protected abstract float missRate(T store)
Return the miss rate for the supplied store.

Parameters:
store - store to query
Returns:
miss rate

countSize

protected abstract long countSize(T store)
Return the number of mappings in the supplied store.

Parameters:
store - store to size
Returns:
mapping count

byteSize

protected abstract long byteSize(T store)
Return the size in bytes of the supplied store.

Parameters:
store - store to size
Returns:
size in bytes

freeSpace

public boolean freeSpace(Collection<T> from,
                         long bytes)
Free at least N bytes from a collection of resources

Specified by:
freeSpace in interface PoolEvictor<T>
Parameters:
from - a collection of resources to free from
bytes - the number of bytes to free up
Returns:
true if at least N bytes could be freed

ehcache

Copyright © 2003-2012 Terracotta, Inc.. All Rights Reserved.