Interface CacheReplacementPolicy<IdType,ObjectType,EntryType extends CacheEntry<ObjectType>>

All Known Implementing Classes:
CacheReplacementPolicyLRU

public interface CacheReplacementPolicy<IdType,ObjectType,EntryType extends CacheEntry<ObjectType>>
Interface for classes that implement a replacement policy for a cache.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Used by the cache to inform the replacement policy that the cache has been cleared.
    void
    Used by the cache to inform the replacement policy that the given entry has been added to the cache (which includes that the given ID is new).
    void
    Used by the cache to inform the replacement policy that the given entry has been evicted from the cache.
    void
    Used by the cache to inform the replacement policy that the given entry has been requested from the cache.
    void
    Used by the cache to inform the replacement policy that the given entry has been added to the cache as a new entry for the given ID.
    getEvictionCandidates(int numberOfCandidates)
    Tries to determine the given number of cache entries as next candidates to be evicted from the cache.
  • Method Details

    • getEvictionCandidates

      Iterable<IdType> getEvictionCandidates(int numberOfCandidates)
      Tries to determine the given number of cache entries as next candidates to be evicted from the cache. The candidates are identified by the corresponding ID with which these entries are associated in the cache. While the identified entries are considered as candidates, they are not yet considered to be evicted (once they are, the cache will inform the replacement policy by calling entryWasEvicted(Object). This method may not return as many candidates as requests, (e.g., if there are not enough entries).
    • entryWasAdded

      void entryWasAdded(IdType id, EntryType e)
      Used by the cache to inform the replacement policy that the given entry has been added to the cache (which includes that the given ID is new).
    • entryWasRewritten

      void entryWasRewritten(IdType id, EntryType e)
      Used by the cache to inform the replacement policy that the given entry has been added to the cache as a new entry for the given ID.
    • entryWasRequested

      void entryWasRequested(IdType id, EntryType e)
      Used by the cache to inform the replacement policy that the given entry has been requested from the cache.
    • entryWasEvicted

      void entryWasEvicted(IdType id)
      Used by the cache to inform the replacement policy that the given entry has been evicted from the cache.
    • clear

      void clear()
      Used by the cache to inform the replacement policy that the cache has been cleared.