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.booleanstatic CacheKeyConstructs a newCacheKeyinstance for the giventenantIdandprincipalId, independent of whether they arenullor 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.inthashCode()static CacheKeyConstructs aCacheKeyfor the given tenant and principal identifier, independent of whether they arenullor not.static CacheKeyConstructs an instance ofCacheKeywithout tenant or principal isolation.static CacheKeyConstructs a tenant- and principal-isolated instance ofCacheKey.static CacheKeyConstructs a tenant- and principal-optional-isolated instance ofCacheKey.static CacheKeyConstructs a tenant-isolated instance ofCacheKey.static CacheKeyConstructs a tenant-optional-isolated instance ofCacheKey.toString()
-
Method Details
-
getTenantId
Description copied from interface:GenericCacheKeyGetter for the Id of the tenant for which the key is used.- Specified by:
getTenantIdin interfaceGenericCacheKey<CacheKey,Object> - Returns:
- The tenant identifier.
-
getPrincipalId
Description copied from interface:GenericCacheKeyGetter for the name of the principal for which the key is used.- Specified by:
getPrincipalIdin interfaceGenericCacheKey<CacheKey,Object> - Returns:
- The principal identifier.
-
append
Description copied from interface:GenericCacheKeyAppends 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:
appendin 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 aCacheKeyfor the given tenant and principal identifier, independent of whether they arenullor 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
CacheKeyconstructed from the given tenant and principal identifier.
-
fromIds
@Beta @Nonnull public static CacheKey fromIds(@Nullable String tenantId, @Nullable String principalId) Constructs a newCacheKeyinstance for the giventenantIdandprincipalId, independent of whether they arenullor 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
CacheKeyconstructed from the given tenant and principal identifier. - Since:
- 4.6.0
-
ofNoIsolation
Constructs an instance ofCacheKeywithout tenant or principal isolation. This can be used to share a cache globally within the application.- Returns:
- A new
CacheKeywithout 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
CacheKeywith 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
CacheKeywith 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
CacheKeywith 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
CacheKeywith tenant- and principal-optional isolation based on the current tenant and principal.
-
equals
-
hashCode
public int hashCode() -
toString
-
getComponents
Description copied from interface:GenericCacheKeyGetter for the list of additional cache key components.- Specified by:
getComponentsin interfaceGenericCacheKey<CacheKey,Object> - Returns:
- The list of additional cache key components.
-