Class AbstractCache<R extends CachedResult>

java.lang.Object
eu.europa.esig.dss.tsl.cache.AbstractCache<R>
Type Parameters:
R - implementation of CachedResult interface
Direct Known Subclasses:
DownloadCache, ParsingCache, ValidationCache

public abstract class AbstractCache<R extends CachedResult> extends Object
The abstract class containing basic methods for handling the Result implementations
  • Constructor Details

    • AbstractCache

      protected AbstractCache()
      Default constructor instantiating cache with empty map
  • Method Details

    • getKeys

      public Set<CacheKey> getKeys()
      Returns all current keys
      Returns:
      a set with all current keys
    • get

      public CachedEntry<R> get(CacheKey cacheKey)
      Returns the CachedEntry for the related cacheKey. Returns new empty entry if no result found for the key
      Parameters:
      cacheKey - CacheKey
      Returns:
      CachedEntry
    • update

      public void update(CacheKey cacheKey, R result)
      Updates in the cache the value for cacheKey with the given result
      Parameters:
      cacheKey - CacheKey key to update value for
      result - CachedResult to store
    • expire

      public void expire(CacheKey cacheKey)
      Updates the state for a CachedEntry matching to the given key to EXPIRED
      Parameters:
      cacheKey - CacheKey of a CachedEntry to update
    • remove

      public void remove(CacheKey cacheKey)
      Removes the requested entry with the given cacheKey
      Parameters:
      cacheKey - CacheKey of the entry to be deleted from the cache
    • sync

      public void sync(CacheKey cacheKey)
      Updates the state for a CachedEntry matching to the given key to SYNCHRONIZED
      Parameters:
      cacheKey - CacheKey of a CachedEntry to update
    • isRefreshNeeded

      public boolean isRefreshNeeded(CacheKey cacheKey)
      Checks if a CachedEntry for the given key is not up to date
      Parameters:
      cacheKey - CacheKey of the CacheEntry to check
      Returns:
      TRUE if update is required for the matching CachedKey, FALSE otherwise
    • isDesync

      public boolean isDesync(CacheKey cacheKey)
      Checks if a CachedEntry for the given key is not up to date
      Parameters:
      cacheKey - CacheKey of the CacheEntry to check
      Returns:
      TRUE if update is required for the matching CachedKey, FALSE otherwise
    • isEmpty

      public boolean isEmpty(CacheKey cacheKey)
      Checks if a CachedEntry for the given key is empty (has no result)
      Parameters:
      cacheKey - CacheKey of the CacheEntry to check
      Returns:
      TRUE if the entry is empty, FALSE otherwise
    • error

      public void error(CacheKey cacheKey, Exception e)
      Updates entry status to ERROR value
      Parameters:
      cacheKey - CacheKey to update
      e - Exception the thrown exception
    • toBeDeleted

      public void toBeDeleted(CacheKey cacheKey)
      Updates entry status to TO_BE_DELETED value
      Parameters:
      cacheKey - CacheKey to update
    • isToBeDeleted

      public boolean isToBeDeleted(CacheKey cacheKey)
      Checks if the requested cacheKey has TO_BE_DELETED value
      Parameters:
      cacheKey - CacheKey to check
      Returns:
      TRUE if the entry with the provided cacheKey has TO_BE_DELETED status, FALSE otherwise
    • getCacheType

      protected abstract CacheType getCacheType()
      Returns a type of current Cache
      Returns:
      CacheType
    • dump

      public String dump()
      Produces a report of the current cache state
      Returns:
      String the cache report