ehcache

net.sf.ehcache.pool.impl
Class AbstractFromLargestCachePoolEvictor

java.lang.Object
  extended by net.sf.ehcache.pool.impl.AbstractFromLargestCachePoolEvictor
All Implemented Interfaces:
PoolEvictor<PoolableStore>
Direct Known Subclasses:
FromLargestCacheOnDiskPoolEvictor, FromLargestCacheOnHeapPoolEvictor

public abstract class AbstractFromLargestCachePoolEvictor
extends Object
implements PoolEvictor<PoolableStore>

Abstract pool evictor which always evicts from the store consuming the most resources.

Author:
Ludovic Orban

Constructor Summary
AbstractFromLargestCachePoolEvictor()
           
 
Method Summary
protected abstract  boolean evict(int count, long bytes, PoolableStore poolableStore)
          Evict from a store for a chosen resource
 boolean freeSpace(Collection<PoolableStore> from, long bytes)
          Free at least N bytes from a collection of resources
protected abstract  long getSizeInBytes(PoolableStore poolableStore)
          Get a store size in bytes for a chosen resource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFromLargestCachePoolEvictor

public AbstractFromLargestCachePoolEvictor()
Method Detail

freeSpace

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

Specified by:
freeSpace in interface PoolEvictor<PoolableStore>
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

evict

protected abstract boolean evict(int count,
                                 long bytes,
                                 PoolableStore poolableStore)
Evict from a store for a chosen resource

Parameters:
count - the element count
bytes - the bytes count
poolableStore - the store
Returns:
true if eviction succeeded, ie: if there was enough evictable resource held by the store

getSizeInBytes

protected abstract long getSizeInBytes(PoolableStore poolableStore)
Get a store size in bytes for a chosen resource

Parameters:
poolableStore - the store
Returns:
the size in bytes

ehcache

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