ehcache

net.sf.ehcache.pool
Interface PoolAccessor<T>

Type Parameters:
T - type of the store that uses this accessor
All Known Implementing Classes:
AbstractPoolAccessor

public interface PoolAccessor<T>

PoolAccessors are used by stores to tell the pools about their resource consumption

Author:
Ludovic Orban

Method Summary
 long add(Object key, Object value, Object container, boolean force)
          Add an element to the pool.
 boolean canAddWithoutEvicting(Object key, Object value, Object container)
          Check if there is enough room in the pool to add an element without provoking any eviction
 void clear()
          Free resources used by this accessor.
 long delete(long size)
          Delete a fixed number of bytes from the pool.
 long getSize()
          Return how many bytes this accessor consumes from the pool.
 T getStore()
          Return the store that uses this accessor
 boolean hasAbortedSizeOf()
          Check if the store may contain elements which the SizeOf engine could not fully size.
 long replace(long currentSize, Object key, Object value, Object container, boolean force)
          Delete a fixed number of bytes from the pool with the given objects.
 void setMaxSize(long newValue)
          Sets the max size for this pool
 void unlink()
          unlink this PoolAccessor from its pool.
 

Method Detail

add

long add(Object key,
         Object value,
         Object container,
         boolean force)
Add an element to the pool.

Parameters:
key - the key of the element
value - the value of the element
container - the element-container object
force - true if the pool should accept adding the element, even if it's out of resources
Returns:
how many bytes have been added to the pool or -1 if add failed.

canAddWithoutEvicting

boolean canAddWithoutEvicting(Object key,
                              Object value,
                              Object container)
Check if there is enough room in the pool to add an element without provoking any eviction

Parameters:
key - the key of the element
value - the value of the element
container - the element-container object
Returns:
true if there is enough room left

delete

long delete(long size)
Delete a fixed number of bytes from the pool.

Parameters:
size - number of bytes
Returns:
how many bytes have been freed from the pool.

replace

long replace(long currentSize,
             Object key,
             Object value,
             Object container,
             boolean force)
Delete a fixed number of bytes from the pool with the given objects.

Parameters:
currentSize - the size of the object(s) being replaced
key - the key of the element
value - the value of the element
container - the element-container object
force - true if the pool should accept replacing the element, even if it's out of resources
Returns:
the change in size of the pool.

getSize

long getSize()
Return how many bytes this accessor consumes from the pool.

Returns:
how many bytes this accessor consumes from the pool.

unlink

void unlink()
unlink this PoolAccessor from its pool.


clear

void clear()
Free resources used by this accessor.


getStore

T getStore()
Return the store that uses this accessor

Returns:
store using this accessor

setMaxSize

void setMaxSize(long newValue)
Sets the max size for this pool

Parameters:
newValue - the value in bytes

hasAbortedSizeOf

boolean hasAbortedSizeOf()
Check if the store may contain elements which the SizeOf engine could not fully size.

Returns:
true if the store may contain partially sized objects

ehcache

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