Interface AsCacheStrategy

All Known Implementing Classes:
DefaultAsCacheStrategy

public interface AsCacheStrategy
Abstraction for interactions with the cache.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the cache by removing all cached entries.
    long
    Returns the hit count.
    long
    Returns the miss count.
    long
    Returns number of elements currently in the cache.
    <V> V
    getWithLoader(AsCacheKey cacheKey, Function<AsCacheKey,V> valueLoader)
    Returns the value in the cache for the given key.
    boolean
    isEnabled(AsCacheScope cacheScope)
    Checks if the cache is enabled for the given AsCacheScope.
  • Method Details

    • isEnabled

      boolean isEnabled(AsCacheScope cacheScope)
      Checks if the cache is enabled for the given AsCacheScope.
      Returns:
      true if the cache is enabled, false otherwise
    • getWithLoader

      <V> V getWithLoader(AsCacheKey cacheKey, Function<AsCacheKey,V> valueLoader)
      Returns the value in the cache for the given key. If the key is null or the value is not yet in the cache, valueLoader will be used to load the missing value.
      Parameters:
      cacheKey - - the cache key
      valueLoader - - function to load values
      Returns:
      the cached value
    • clear

      void clear()
      Clears the cache by removing all cached entries.
    • getSize

      long getSize()
      Returns number of elements currently in the cache.
    • getHits

      long getHits()
      Returns the hit count.
    • getMisses

      long getMisses()
      Returns the miss count.