Interface CacheOperation

  • All Known Subinterfaces:

    public interface CacheOperation
    Commands to influence the cache operation in general.

    All commands return a CompletableFuture. A cache client may choose to wait for the operation to complete or not. As of version 2.0 all operations are completed instantly within the calling thread. This will change in later versions.

    Outlook: Could get ability to control expiry and refresh behavior, as well as disable the cache.

    Jens Wilke
    • Method Detail

      • removeAll

        CompletableFuture<Void> removeAll()
        Removes all cache contents. This has the same semantics of calling remove to every key, except that the cache is trying to optimize the bulk operation. Same as clear but listeners will be called.
      • destroy

        CompletableFuture<Void> destroy()
        A combination of Cache.clear() and Cache.close() potentially wiping all stored data of this cache.

        This method is to future proof the API, when a persistence feature is added. In this case the method will stop cache operations and remove all stored external data.

        Rationale: The corresponding method in JSR107 is CacheManager.destroyCache().

        See class description
      • changeCapacity

        CompletableFuture<Void> changeCapacity​(long entryCountOrWeight)
        Change the maximum capacity of the cache. If a weigher is present this is the maximum weight of all cache entries, otherwise the maximum count of cache entries. The capacity is not allowed to be 0.
        entryCountOrWeight - either maximum number of entries or maximum weight
        See class description
        See Also: