org.exist.storage.cache
Interface Cacheable

All Known Implementing Classes:
Collection

public interface Cacheable

Implemented by all objects that should be stored into a cache. Each object should provide a unique key, an internal reference counter, and a timestamp marker (used to measure how long the object has stayed in the cache). It depends on the concrete cache implementation if and how these fields are used.

Author:
Wolfgang

Field Summary
static int MAX_REF
           
 
Method Summary
 boolean allowUnload()
          Is it safe to unload the Cacheable from the cache? Called before an object is actually removed.
 int decReferenceCount()
          Decrease the reference count of this object by one and return it.
 long getKey()
          Get a unique key for the object.
 int getReferenceCount()
          Get the current reference count.
 int getTimestamp()
          Get the current timestamp marker.
 int incReferenceCount()
          Increase the reference count of this object by one and return it.
 boolean isDirty()
           
 void setReferenceCount(int count)
          Set the reference count of this object.
 void setTimestamp(int timestamp)
          Set the timestamp marker.
 boolean sync(boolean syncJournal)
          Called before the object is released by the cache.
 

Field Detail

MAX_REF

public static final int MAX_REF
See Also:
Constant Field Values
Method Detail

getKey

public long getKey()
Get a unique key for the object. Usually this is the page number.

Returns:
unique key

getReferenceCount

public int getReferenceCount()
Get the current reference count.

Returns:
The count value.

incReferenceCount

public int incReferenceCount()
Increase the reference count of this object by one and return it.

Returns:
the reference count

decReferenceCount

public int decReferenceCount()
Decrease the reference count of this object by one and return it.

Returns:
the reference count

setReferenceCount

public void setReferenceCount(int count)
Set the reference count of this object.

Parameters:
count -

setTimestamp

public void setTimestamp(int timestamp)
Set the timestamp marker.

Parameters:
timestamp -

getTimestamp

public int getTimestamp()
Get the current timestamp marker.

Returns:
timestamp marker

sync

public boolean sync(boolean syncJournal)
Called before the object is released by the cache. The object should prepare to be garbage collected. All unwritten data should be flushed to disk.


allowUnload

public boolean allowUnload()
Is it safe to unload the Cacheable from the cache? Called before an object is actually removed. Return false to avoid being removed.

Returns:
A boolean where true indicates it can be unloaded.

isDirty

public boolean isDirty()


Copyright (C) Wolfgang Meier. All rights reserved.