public final class CacheKey extends Object implements GenericCacheKey<CacheKey,Object>
| Modifier and Type | Method and Description |
|---|---|
CacheKey |
append(Iterable<Object> objects)
Appends the given Objects to this instance.
|
CacheKey |
append(Object... objects)
Appends the given Objects to this instance.
|
boolean |
equals(Object o) |
List<Object> |
getComponents()
Getter for the list of additional cache key components.
|
io.vavr.control.Option<String> |
getPrincipalId()
Getter for the name of the principal for which the key is used.
|
io.vavr.control.Option<String> |
getTenantId()
Getter for the Id of the tenant or zone for which the key is used.
|
int |
hashCode() |
static CacheKey |
of(Tenant tenant,
Principal principal)
Constructs a
CacheKey for the given tenant and principal identifier, independent of whether they are
null or not. |
static CacheKey |
ofNoIsolation()
Constructs an instance of
CacheKey without tenant or principal isolation. |
static CacheKey |
ofTenantAndPrincipalIsolation()
Constructs a tenant- and principal-isolated instance of
CacheKey. |
static CacheKey |
ofTenantAndPrincipalOptionalIsolation()
Constructs a tenant- and principal-optional-isolated instance of
CacheKey. |
static CacheKey |
ofTenantIsolation()
Constructs a tenant-isolated instance of
CacheKey. |
static CacheKey |
ofTenantOptionalIsolation()
Constructs a tenant-optional-isolated instance of
CacheKey. |
String |
toString() |
@Nonnull public io.vavr.control.Option<String> getTenantId()
GenericCacheKeygetTenantId in interface GenericCacheKey<CacheKey,Object>@Nonnull public io.vavr.control.Option<String> getPrincipalId()
GenericCacheKeygetPrincipalId in interface GenericCacheKey<CacheKey,Object>@Nonnull public CacheKey append(@Nonnull Iterable<Object> objects) throws IllegalArgumentException
GenericCacheKeyObject.equals(Object) and
Object.hashCode() are used. The given objects must not be null.append in interface GenericCacheKey<CacheKey,Object>objects - Additional objects that should be used to identify a cache key.IllegalArgumentException - If any of the given objects is null.@Nonnull public CacheKey append(@Nonnull Object... objects)
Object.equals(Object) and
Object.hashCode() are used. The given objects must not be null.objects - Additional objects that should be used to identify a cache key.IllegalArgumentException - If any of the given objects is null.@Nonnull public static CacheKey of(@Nullable Tenant tenant, @Nullable Principal principal)
CacheKey for the given tenant and principal identifier, independent of whether they are
null or not. This provides the highest flexibility for defining different levels of isolation.tenant - The tenant. If null, there is not tenant isolation.principal - The principal. If null, there is no principal isolation.CacheKey constructed from the given tenant and principal identifier.@Nonnull public static CacheKey ofNoIsolation()
CacheKey without tenant or principal isolation. This can be used to share a
cache globally within the application.CacheKey without isolation.@Nonnull public static CacheKey ofTenantIsolation() throws TenantAccessException
CacheKey. This can be used to share a cache among the principals
of a tenant.
When using this method, the tenant isolation is strictly enforced. This means that if the tenant is not available, an exception is thrown.
CacheKey with tenant isolation based on the current tenant.TenantAccessException - If there is an issue while accessing the tenant.@Nonnull public static CacheKey ofTenantOptionalIsolation()
CacheKey. This can be used to share a cache among the
principals of a tenant.
When using this method, the tenant isolation is not enforced. This means that if the tenant is not available, an no isolation will be applied.
CacheKey with tenant-optional isolation based on the current tenant.@Nonnull public static CacheKey ofTenantAndPrincipalIsolation() throws TenantAccessException, PrincipalAccessException
CacheKey.
When using this method, the tenant and principal isolation is strictly enforced. This means that if the tenant is not available or the principal is not authenticated, an exception is thrown.
CacheKey with tenant and principal isolation based on the current tenant and principal.TenantAccessException - If there is an issue while accessing the tenant.PrincipalAccessException - If there is an issue while accessing the principal.@Nonnull public static CacheKey ofTenantAndPrincipalOptionalIsolation()
CacheKey.
When using this method, the tenant and principal isolation is not enforced. This means that if the tenant is not available or the principal is not authenticated, the missing information is not used for isolation.
CacheKey with tenant- and principal-optional isolation based on the current tenant and
principal.public List<Object> getComponents()
GenericCacheKeygetComponents in interface GenericCacheKey<CacheKey,Object>Copyright © 2022 SAP SE. All rights reserved.