Interface CacheFilter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a filter function to select specific parts of a cache depending on a
ResilienceConfiguration
, a
GenericCacheKey
, and a cache entry.-
Method Summary
Modifier and TypeMethodDescriptionstatic CacheFilter
and
(CacheFilter firstFilter, CacheFilter... additionalFilters) Creates a newCacheFilter
instance which represents the conjunction of all passed cache filters.static CacheFilter
Creates aCacheFilter
, which matches all cache entries associated withGenericCacheKey
s that are accessible with respect to the parameters in theResilienceConfiguration.CacheConfiguration
in the correspondingResilienceConfiguration
.static CacheFilter
keyMatchesParameters
(Iterable<Object> parameters) Creates aCacheFilter
, which includes all cache entries associated withGenericCacheKey
s that are accessible with respect to the passed parameters.static CacheFilter
Creates aCacheFilter
, which matches all cache entries associated withGenericCacheKey
s that are accessible with respect to thePrincipal
used at the time when theCacheFilter
is applied.
Whether theCacheFilter
considers thePrincipal
, depends on theResilienceIsolationMode
stored in the correspondingResilienceConfiguration
.static CacheFilter
keyMatchesPrincipal
(Principal principal) Creates aCacheFilter
, which includes all cache entries associated withGenericCacheKey
s that are accessible with respect to the passedPrincipal
.static CacheFilter
Creates aCacheFilter
, which matches all cache entries associated withGenericCacheKey
s that are accessible with respect to theTenant
used at the time when theCacheFilter
is applied.
Whether theCacheFilter
considers theTenant
, depends on theResilienceIsolationMode
stored in the correspondingResilienceConfiguration
.static CacheFilter
keyMatchesTenant
(Tenant tenant) Creates aCacheFilter
, which includes all cache entries associated withGenericCacheKey
s that are accessible with respect to the passedTenant
.boolean
matches
(ResilienceConfiguration configuration, GenericCacheKey<?, ?> cacheKey, Object cacheEntry) Determines whether a specific cache entry matches the expectations of this cache filter.static CacheFilter
or
(CacheFilter firstFilter, CacheFilter... additionalFilters) Creates a newCacheFilter
instance which represents the disjunction of all passed cache filters.
-
Method Details
-
matches
boolean matches(@Nonnull ResilienceConfiguration configuration, @Nonnull GenericCacheKey<?, ?> cacheKey, @Nullable Object cacheEntry) Determines whether a specific cache entry matches the expectations of this cache filter.- Parameters:
configuration
- TheResilienceConfiguration
that is used for the current cache access operation.cacheKey
- TheGenericCacheKey
that is associated with the current cache entry.cacheEntry
- The actual cache entry.- Returns:
true
if the cache entry should be included,false
otherwise.
-
keyMatchesTenant
Creates aCacheFilter
, which includes all cache entries associated withGenericCacheKey
s that are accessible with respect to the passedTenant
.- Parameters:
tenant
- The tenant- Returns:
- A
CacheFilter
that respects the provided tenant.
-
keyMatchesPrincipal
Creates aCacheFilter
, which matches all cache entries associated withGenericCacheKey
s that are accessible with respect to thePrincipal
used at the time when theCacheFilter
is applied.
Whether theCacheFilter
considers thePrincipal
, depends on theResilienceIsolationMode
stored in the correspondingResilienceConfiguration
.- Returns:
- A
CacheFilter
that respects principal isolation.
-
keyMatchesPrincipal
Creates aCacheFilter
, which includes all cache entries associated withGenericCacheKey
s that are accessible with respect to the passedPrincipal
.- Parameters:
principal
- The principal- Returns:
- A
CacheFilter
that respects the provided principal id
-
keyMatchesTenant
Creates aCacheFilter
, which matches all cache entries associated withGenericCacheKey
s that are accessible with respect to theTenant
used at the time when theCacheFilter
is applied.
Whether theCacheFilter
considers theTenant
, depends on theResilienceIsolationMode
stored in the correspondingResilienceConfiguration
.- Returns:
- A
CacheFilter
that respects tenant isolation.
-
keyMatchesParameters
Creates aCacheFilter
, which matches all cache entries associated withGenericCacheKey
s that are accessible with respect to the parameters in theResilienceConfiguration.CacheConfiguration
in the correspondingResilienceConfiguration
.- Returns:
- A
CacheFilter
that respects the cache parameters
-
keyMatchesParameters
Creates aCacheFilter
, which includes all cache entries associated withGenericCacheKey
s that are accessible with respect to the passed parameters.- Parameters:
parameters
- The parameters- Returns:
- A
CacheFilter
that respects the provided parameters
-
and
@Nonnull static CacheFilter and(@Nonnull CacheFilter firstFilter, @Nonnull CacheFilter... additionalFilters) Creates a newCacheFilter
instance which represents the conjunction of all passed cache filters.- Parameters:
firstFilter
- The first cache filter for the conjunctionadditionalFilters
- All additional cache filters which shall be applied as one conjunction- Returns:
- The conjunction of all cache filters
-
or
@Nonnull static CacheFilter or(@Nonnull CacheFilter firstFilter, @Nonnull CacheFilter... additionalFilters) Creates a newCacheFilter
instance which represents the disjunction of all passed cache filters.- Parameters:
firstFilter
- The first cache filter for the disjunctionadditionalFilters
- All additional cache filters which shall be applied as one disjunction- Returns:
- The disjunction of all cache filters
-