Interface ManagedCache


@Internal public interface ManagedCache
Interface that managed cache things need to implement
Since:
2.0
  • Method Details

    • clear

      void clear()
      Clear the cache.
    • getName

      @Nonnull String getName()
      The name of the cache, uniquely identifies this cache.
      Returns:
      the name of the cache.
    • isFlushable

      boolean isFlushable()
      Returns true if this cache can be safely flushed any time.

      This method is used by CacheManager.flushCaches() to only flush caches that can be safely flushed. clear() ignores this value.

      Returns:
      true if this cache can be flushed safely.
    • currentMaxEntries

      @Nullable Integer currentMaxEntries()
      Returns:
      the current hint regarding the maximum number of entries that should be cached at any time. null indicates no current hint
    • updateMaxEntries

      boolean updateMaxEntries(int newValue)
      Attempts to update the hint regarding the maximum number of entries that should be cached at any time.
      Parameters:
      newValue - the new hint value
      Returns:
      true iff the hint has been updated to the new value. If a cache does not support changes at run-time, it must return false
    • currentExpireAfterAccessMillis

      @Nullable Long currentExpireAfterAccessMillis()
      Returns:
      the current hint regarding how long entries should be held in the cache, after last access, measured in milliseconds. null indicates no current hint
    • updateExpireAfterAccess

      boolean updateExpireAfterAccess(long expireAfter, @Nonnull TimeUnit timeUnit)
      Attempts to update the hint regarding how long entries that should be held in the cache, after last access.
      Parameters:
      expireAfter - Time to retain entries for since their last access.
      timeUnit - The TimeUnit for the time
      Returns:
      true iff the hint has been updated to the new value. If a cache does not support changes at run-time, it must return false
    • currentExpireAfterWriteMillis

      @Nullable Long currentExpireAfterWriteMillis()
      Returns:
      the current hint regarding how long entries should be held in the cache, after last write, measured in milliseconds. null indicates no current hint
    • updateExpireAfterWrite

      boolean updateExpireAfterWrite(long expireAfter, @Nonnull TimeUnit timeUnit)
      Attempts to update the hint regarding how long entries that should be held in the cache, after last write.
      Parameters:
      expireAfter - Time to retain entries for since their last write.
      timeUnit - The TimeUnit for the time
      Returns:
      true iff the hint has been updated to the new value. If a cache does not support changes at run-time, it must return false
    • isLocal

      boolean isLocal()
      Returns:
      true if the cache is local, and hence is not replicated in a clustered environment
    • isReplicateAsynchronously

      boolean isReplicateAsynchronously()
      Returns:
      true if this cache should be replicated asynchronously in a clustered environment.
    • isReplicateViaCopy

      boolean isReplicateViaCopy()
      Returns:
      true if this cache should, in a clustered environment, replicate put and update operations by copying the relevant key and value across the wire (as opposed to just the key).
    • isStatisticsEnabled

      boolean isStatisticsEnabled()
      Returns:
      true if this cache gathers statistics.
    • setStatistics

      @Deprecated void setStatistics(boolean enabled)
      Deprecated.
      Use CacheCollector.setEnabled(boolean) instead for memory caches. This method was never implemented for other cache types.
      Changes the state of statistics gathering.
      Parameters:
      enabled - The stats collection is enabled if true - disabled otherwise.
      Since:
      2.8.4
    • getStatistics

      @Nonnull SortedMap<CacheStatisticsKey,Supplier<Long>> getStatistics()
      Get usage statistics for the cache.

      The statistics are sorted by the cache statistics key labels. Providing statistics is an optional feature and no assumptions should be made by the caller about which (if any) statistics will be returned.

      Returns:
      a map of statistics keys to suppliers for their values, sorted lexically by the statistics key's label
      Since:
      v2.4.0
    • getCacheCollector

      @Nullable default com.atlassian.instrumentation.caches.CacheCollector getCacheCollector()
      Returns the collector for this cache.
      Returns:
      The CacheCollector for this cache.
      Since:
      2.8.4