Class CacheManager

java.lang.Object
com.sap.cloud.sdk.cloudplatform.cache.CacheManager

public final class CacheManager extends Object
Grants bulk processing for all (statically) registered caches.
  • Constructor Details

    • CacheManager

      public CacheManager()
  • Method Details

    • getCacheList

      @Nonnull public static com.google.common.collect.ImmutableList<com.github.benmanes.caffeine.cache.Cache<CacheKey,?>> getCacheList()
      Getter for a list of all caches registered in the CacheManager.
      Returns:
      The list of all caches.
    • register

      @Nonnull public static <T> com.github.benmanes.caffeine.cache.Cache<CacheKey,T> register(@Nonnull com.github.benmanes.caffeine.cache.Cache<CacheKey,T> cache)
      Registers a cache at in the CacheManager.
      Type Parameters:
      T - The type of the values in the cache.
      Parameters:
      cache - The cache to be registered.
      Returns:
      The given cache.
    • unregister

      @Beta @Nonnull public static <T> com.github.benmanes.caffeine.cache.Cache<CacheKey,T> unregister(@Nonnull com.github.benmanes.caffeine.cache.Cache<CacheKey,T> cache)
      Unregisters a cache from the CacheManager.

      Note: The given cache will not be cleared / manipulated with this method.

      Type Parameters:
      T - The type of the values for the cache.
      Parameters:
      cache - The cache to be unregistered.
      Returns:
      The given cache.
      Since:
      4.3.0
    • cleanUp

      public static void cleanUp()
      Cleans up all cache entries that have been invalidated.
    • invalidateAll

      public static long invalidateAll()
      Invalidates all entries in all caches.
      Returns:
      The number of invalidated cache entries.
    • invalidateTenantCaches

      public static long invalidateTenantCaches()
      Invalidates all caches of the current tenant.
      Returns:
      The number of invalidated cache entries.
    • invalidateTenantCaches

      public static long invalidateTenantCaches(@Nullable String tenantId)
      Invalidates all caches of the given tenant.
      Parameters:
      tenantId - The tenant to invalidate all caches for.
      Returns:
      The number of invalidated cache entries.
    • invalidatePrincipalCaches

      public static long invalidatePrincipalCaches()
      Invalidates all caches of the current principal.
      Returns:
      The number of invalidated cache entries.
    • invalidatePrincipalCaches

      public static long invalidatePrincipalCaches(@Nullable String tenantId, @Nullable String principalId)
      Invalidates all caches of the given principal.
      Parameters:
      tenantId - The identifier of the tenant for which all principal caches should be invalidated.
      principalId - The identifier of the principal for which all caches should be invalidated.
      Returns:
      The number of invalidated cache entries.
    • invalidatePrincipalEntries

      public static long invalidatePrincipalEntries(@Nonnull com.github.benmanes.caffeine.cache.Cache<CacheKey,?> cache)
      Invalidates all cache entries of the current tenant-specific principal.
      Parameters:
      cache - The cache in which all caches of the current principal should be invalidated.
      Returns:
      The number of invalidated cache entries.
    • invalidatePrincipalEntries

      public static long invalidatePrincipalEntries(@Nullable String tenantId, @Nullable String principalId, @Nonnull com.github.benmanes.caffeine.cache.Cache<CacheKey,?> cache)
      Invalidates all cache entries of the given tenant-specific principal.
      Parameters:
      tenantId - The identifier of the tenant for which all principal cache entries should be invalidated.
      principalId - The identifier of the principal for which all cache entries should be invalidated.
      cache - The cache in which the entries of the principal should be invalidated.
      Returns:
      The number of invalidated cache entries.