Class CacheManager
java.lang.Object
com.sap.cloud.sdk.cloudplatform.cache.CacheManager
Grants bulk processing for all (statically) registered caches.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
cleanUp()
Cleans up all cache entries that have been invalidated.static com.google.common.collect.ImmutableList<com.github.benmanes.caffeine.cache.Cache<CacheKey,
?>> Getter for a list of all caches registered in theCacheManager
.static long
Invalidates all entries in all caches.static long
Invalidates all caches of the current principal.static long
invalidatePrincipalCaches
(String tenantId, String principalId) Invalidates all caches of the given principal.static long
invalidatePrincipalEntries
(com.github.benmanes.caffeine.cache.Cache<CacheKey, ?> cache) Invalidates all cache entries of the current tenant-specific principal.static long
invalidatePrincipalEntries
(String tenantId, String principalId, com.github.benmanes.caffeine.cache.Cache<CacheKey, ?> cache) Invalidates all cache entries of the given tenant-specific principal.static long
Invalidates all caches of the current tenant.static long
invalidateTenantCaches
(String tenantId) Invalidates all caches of the given tenant.static <T> com.github.benmanes.caffeine.cache.Cache<CacheKey,
T> Registers a cache at in theCacheManager
.static <T> com.github.benmanes.caffeine.cache.Cache<CacheKey,
T> unregister
(com.github.benmanes.caffeine.cache.Cache<CacheKey, T> cache) Unregisters a cache from theCacheManager
.
-
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 theCacheManager
.- 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 theCacheManager
.- Type Parameters:
T
- The type of the values in the cache.- Parameters:
cache
- The cache to be registered.- Returns:
- The given cache.
-
unregister
@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 theCacheManager
.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
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.
-