Top Description Inners Methods
org.apache.derby.impl.services.cache

pack-priv Interface ReplacementPolicy

Known Direct Implementers
org.apache.derby.impl.services.cache.ClockPolicy
Imports
org.apache.derby.shared.common.error.StandardException

Interface that must be implemented by classes that provide a replacement algorithm for ConcurrentCache.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ReplacementPolicy.Callback

The interface for the callback objects that ConcurrentCache uses to notify the replacement algorithm about events such as look-ups and removals.

Method Summary

Modifier and TypeMethod and Description
public void
doShrink()

Try to shrink the cache if it has exceeded its maximum size.

public void
insertEntry(CacheEntry
the entry to insert
entry
)

Insert an entry into the ReplacementPolicy's data structure, possibly evicting another entry.

public int

Returns:

the number of entries allocated in the cache
size
()

Get the number of entries allocated in the data structure that holds cached objects.

Method Detail

doShrinkback to summary
public void doShrink()

Try to shrink the cache if it has exceeded its maximum size. It is not guaranteed that the cache will actually shrink.

insertEntryback to summary
public void insertEntry(CacheEntry entry) throws StandardException

Insert an entry into the ReplacementPolicy's data structure, possibly evicting another entry. The entry should be uninitialized when the method is called (that is, its Cacheable should be null), and it should be locked. When the method returns, the entry may have been initialized with a Cacheable which is ready to be reused. It is also possible that the Cacheable is still null when the method returns, in which case the caller must allocate one itself. The entry will be associated with a Callback object that it can use to communicate back to the replacement policy events (for instance, that it has been accessed or become invalid).

Parameters
entry:CacheEntry

the entry to insert

Exceptions
StandardException:
if an error occurs while inserting the entry
See Also
CacheEntry#setCallback(ReplacementPolicy.Callback)
sizeback to summary
public int size()

Get the number of entries allocated in the data structure that holds cached objects. This number could include empty entries for objects that have been removed from the cache, if those entries are still kept in the data structure for reuse.

Returns:int

the number of entries allocated in the cache

org.apache.derby.impl.services.cache back to summary

public Interface ReplacementPolicy.Callback

Known Direct Implementers
org.apache.derby.impl.services.cache.ClockPolicy.Holder

The interface for the callback objects that ConcurrentCache uses to notify the replacement algorithm about events such as look-ups and removals. Each Callback object is associated with a single entry in the cache.

Method Summary

Modifier and TypeMethod and Description
public void
access()

Notify the replacement algorithm that the cache entry has been accessed.

public void
free()

Notify the replacement algorithm that the entry associated with this callback object has been removed, and the callback object and the Cacheable can be reused.

Method Detail

accessback to summary
public void access()

Notify the replacement algorithm that the cache entry has been accessed. The replacement algorithm can use this information to collect statistics about access frequency which can be used to determine the order of evictions.

The entry associated with the callback object must be locked by the current thread.

freeback to summary
public void free()

Notify the replacement algorithm that the entry associated with this callback object has been removed, and the callback object and the Cacheable can be reused.

The entry associated with the callback object must be locked by the current thread.