Class CacheKey
java.lang.Object
com.sap.cloud.sdk.cloudplatform.cache.CacheKey
- All Implemented Interfaces:
GenericCacheKey<CacheKey,
Object>
CacheKey with either global visibility, tenant isolation, or tenant and principal isolation.
-
Method Summary
Modifier and TypeMethodDescriptionAppends the given Objects to this instance.Appends the given Objects to this instance.boolean
static CacheKey
Constructs a newCacheKey
instance for the giventenantId
andprincipalId
, independent of whether they arenull
or not.Getter for the list of additional cache key components.io.vavr.control.Option<String>
Getter for the name of the principal for which the key is used.io.vavr.control.Option<String>
Getter for the Id of the tenant for which the key is used.int
hashCode()
static CacheKey
Constructs aCacheKey
for the given tenant and principal identifier, independent of whether they arenull
or not.static CacheKey
Constructs an instance ofCacheKey
without tenant or principal isolation.static CacheKey
Constructs a tenant- and principal-isolated instance ofCacheKey
.static CacheKey
Constructs a tenant- and principal-optional-isolated instance ofCacheKey
.static CacheKey
Constructs a tenant-isolated instance ofCacheKey
.static CacheKey
Constructs a tenant-optional-isolated instance ofCacheKey
.toString()
-
Method Details
-
getTenantId
Description copied from interface:GenericCacheKey
Getter for the Id of the tenant for which the key is used.- Specified by:
getTenantId
in interfaceGenericCacheKey<CacheKey,
Object> - Returns:
- The tenant identifier.
-
getPrincipalId
Description copied from interface:GenericCacheKey
Getter for the name of the principal for which the key is used.- Specified by:
getPrincipalId
in interfaceGenericCacheKey<CacheKey,
Object> - Returns:
- The principal identifier.
-
append
Description copied from interface:GenericCacheKey
Appends the given Objects to this instance. In order to compare cache keys,Object.equals(Object)
andObject.hashCode()
are used. The given objects must not benull
.- Specified by:
append
in interfaceGenericCacheKey<CacheKey,
Object> - Parameters:
objects
- Additional objects that should be used to identify a cache key.- Returns:
- This instance with the objects added.
- Throws:
IllegalArgumentException
- If any of the given objects isnull
.
-
append
Appends the given Objects to this instance. In order to compare cache keys,Object.equals(Object)
andObject.hashCode()
are used. The given objects must not benull
.- Parameters:
objects
- Additional objects that should be used to identify a cache key.- Returns:
- This instance with the objects added.
- Throws:
IllegalArgumentException
- If any of the given objects isnull
.
-
of
Constructs aCacheKey
for the given tenant and principal identifier, independent of whether they arenull
or not. This provides the highest flexibility for defining different levels of isolation.- Parameters:
tenant
- The tenant. Ifnull
, there is no tenant isolation.principal
- The principal. Ifnull
, there is no principal isolation.- Returns:
- A new
CacheKey
constructed from the given tenant and principal identifier.
-
fromIds
@Beta @Nonnull public static CacheKey fromIds(@Nullable String tenantId, @Nullable String principalId) Constructs a newCacheKey
instance for the giventenantId
andprincipalId
, independent of whether they arenull
or not. This provides the highest flexibility for defining different levels of isolation.- Parameters:
tenantId
- The tenant identifier. Ifnull
, there is no tenant isolation.principalId
- The principal identifier. Ifnull
, there is no principal isolation.- Returns:
- A new
CacheKey
constructed from the given tenant and principal identifier. - Since:
- 4.6.0
-
ofNoIsolation
Constructs an instance ofCacheKey
without tenant or principal isolation. This can be used to share a cache globally within the application.- Returns:
- A new
CacheKey
without isolation.
-
ofTenantIsolation
Constructs a tenant-isolated instance ofCacheKey
. 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.
- Returns:
- A new
CacheKey
with tenant isolation based on the current tenant. - Throws:
TenantAccessException
- If there is an issue while accessing the tenant.
-
ofTenantOptionalIsolation
Constructs a tenant-optional-isolated instance ofCacheKey
. 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.
- Returns:
- A new
CacheKey
with tenant-optional isolation based on the current tenant.
-
ofTenantAndPrincipalIsolation
@Nonnull public static CacheKey ofTenantAndPrincipalIsolation() throws TenantAccessException, PrincipalAccessExceptionConstructs a tenant- and principal-isolated instance ofCacheKey
.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.
- Returns:
- A new
CacheKey
with tenant and principal isolation based on the current tenant and principal. - Throws:
TenantAccessException
- If there is an issue while accessing the tenant.PrincipalAccessException
- If there is an issue while accessing the principal.
-
ofTenantAndPrincipalOptionalIsolation
Constructs a tenant- and principal-optional-isolated instance ofCacheKey
.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.
- Returns:
- A new
CacheKey
with tenant- and principal-optional isolation based on the current tenant and principal.
-
equals
-
hashCode
public int hashCode() -
toString
-
getComponents
Description copied from interface:GenericCacheKey
Getter for the list of additional cache key components.- Specified by:
getComponents
in interfaceGenericCacheKey<CacheKey,
Object> - Returns:
- The list of additional cache key components.
-