Interface ReplacementPolicy
- All Known Implementing Classes:
ClockPolicy
interface ReplacementPolicy
Interface that must be implemented by classes that provide a replacement
algorithm for
ConcurrentCache.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe interface for the callback objects thatConcurrentCacheuses to notify the replacement algorithm about events such as look-ups and removals. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoShrink()Try to shrink the cache if it has exceeded its maximum size.voidinsertEntry(CacheEntry entry) Insert an entry into theReplacementPolicy's data structure, possibly evicting another entry.intsize()Get the number of entries allocated in the data structure that holds cached objects.
-
Method Details
-
insertEntry
Insert an entry into theReplacementPolicy's data structure, possibly evicting another entry. The entry should be uninitialized when the method is called (that is, itsCacheableshould benull), and it should be locked. When the method returns, the entry may have been initialized with aCacheablewhich is ready to be reused. It is also possible that theCacheableis stillnullwhen the method returns, in which case the caller must allocate one itself. The entry will be associated with aCallbackobject that it can use to communicate back to the replacement policy events (for instance, that it has been accessed or become invalid).- Parameters:
entry- the entry to insert- Throws:
StandardException- if an error occurs while inserting the entry- See Also:
-
doShrink
void doShrink()Try to shrink the cache if it has exceeded its maximum size. It is not guaranteed that the cache will actually shrink. -
size
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:
- the number of entries allocated in the cache
-