org.exist.storage.cache
Interface Cache

All Known Implementing Classes:
CollectionCache, GClockCache, LRDCache, LRUCache

public interface Cache

Base interface for all cache implementations that are used for buffering btree and data pages.

Author:
Wolfgang

Field Summary
static Logger LOG
           
 
Method Summary
 void add(Cacheable item)
          Add the item to the cache.
 void add(Cacheable item, int initialRefCount)
          Add the item to the cache.
 boolean flush()
          Call release on all items, but without actually removing them from the cache.
 Cacheable get(Cacheable item)
          Retrieve an item from the cache.
 Cacheable get(long key)
          Retrieve an item by its key.
 int getBuffers()
          Get the size of this cache.
 int getFails()
          Get the number of times where an object could not be found in the cache.
 String getFileName()
           
 double getGrowthFactor()
          Returns the factor by which the cache should grow if it can be resized.
 int getHits()
          Get the number of times where an object has been successfully loaded from the cache.
 int getLoad()
           
 String getType()
          Returns the type of this cache.
 int getUsedBuffers()
          Get the number of buffers currently used.
 boolean hasDirtyItems()
          Returns true if the cache contains any dirty items that need to be written to disk.
 void remove(Cacheable item)
          Remove an item from the cache.
 void resize(int newSize)
          Resize the cache.
 void setCacheManager(CacheManager manager)
          Set the CacheManager object that controls this cache.
 void setFileName(String fileName)
           
 

Field Detail

LOG

static final Logger LOG
Method Detail

getType

String getType()
Returns the type of this cache. Should be one of the constants defined in CacheManager.

Returns:
the type of this cache

add

void add(Cacheable item)
Add the item to the cache. If it is already in the cache, update the references.

Parameters:
item -

add

void add(Cacheable item,
         int initialRefCount)
Add the item to the cache. If it is already in the cache, update the references.

Parameters:
item -
initialRefCount - the initial reference count for the item

get

Cacheable get(Cacheable item)
Retrieve an item from the cache.

Parameters:
item -
Returns:
the item in the cache or null if it does not exist.

get

Cacheable get(long key)
Retrieve an item by its key.

Parameters:
key - a unique key, usually the page number
Returns:
the item in the cache or null if it does not exist.

remove

void remove(Cacheable item)
Remove an item from the cache.

Parameters:
item -

hasDirtyItems

boolean hasDirtyItems()
Returns true if the cache contains any dirty items that need to be written to disk.


flush

boolean flush()
Call release on all items, but without actually removing them from the cache. This gives the items a chance to write all unwritten data to disk.


getBuffers

int getBuffers()
Get the size of this cache.

Returns:
size

getGrowthFactor

double getGrowthFactor()
Returns the factor by which the cache should grow if it can be resized. The returned factor f will be between 0 and 2. A value smaller or equal to 1 means the cache can't grow, 1.5 means it grows by 50 percent. A cache with growth factor <= 1.0 can also not be shrinked. A cache is resized by the DefaultCacheManager.

Returns:
growth factor

resize

void resize(int newSize)
Resize the cache. This method is called by the DefaultCacheManager. The newSize parameter can either be larger or smaller than the current cache size.

Parameters:
newSize - the new size of the cache.

setCacheManager

void setCacheManager(CacheManager manager)
Set the CacheManager object that controls this cache.

Parameters:
manager -

getUsedBuffers

int getUsedBuffers()
Get the number of buffers currently used.


getHits

int getHits()
Get the number of times where an object has been successfully loaded from the cache.


getFails

int getFails()
Get the number of times where an object could not be found in the cache.

Returns:
number of times where an object could not be found in the cache

getLoad

int getLoad()

setFileName

void setFileName(String fileName)

getFileName

String getFileName()


Copyright (C) Wolfgang Meier. All rights reserved.