public final class CustomerGroupServiceImpl extends java.lang.Object implements CustomerGroupService
Modifier and Type | Field and Description |
---|---|
protected com.github.benmanes.caffeine.cache.Cache<java.lang.String,java.lang.String> |
keyToIdCache |
protected static int |
MAXIMUM_ALLOWED_UPDATE_ACTIONS |
Constructor and Description |
---|
CustomerGroupServiceImpl(BaseSyncOptions syncOptions) |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> |
cacheKeysToIds(java.util.Set<java.lang.String> customerGroupKeys)
Filters out the keys which are already cached and fetches only the not-cached customer group
keys from the CTP project defined in an injected
SphereClient and stores a mapping for
every customer group to id in the cached map of keys -> ids and returns this cached map. |
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> |
fetchCachedCustomerGroupId(java.lang.String key)
Given a
key , this method first checks if a cached map of customer group keys -> ids
contains the key. |
protected final com.github.benmanes.caffeine.cache.Cache<java.lang.String,java.lang.String> keyToIdCache
protected static final int MAXIMUM_ALLOWED_UPDATE_ACTIONS
public CustomerGroupServiceImpl(@Nonnull BaseSyncOptions syncOptions)
@Nonnull public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> cacheKeysToIds(@Nonnull java.util.Set<java.lang.String> customerGroupKeys)
CustomerGroupService
SphereClient
and stores a mapping for
every customer group to id in the cached map of keys -> ids and returns this cached map.cacheKeysToIds
in interface CustomerGroupService
customerGroupKeys
- - a set customer group keys to fetch and cache the ids forCompletionStage
<Map
> in which the result of it's completion
contains a map of requested customer group keys -> ids@Nonnull public java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> fetchCachedCustomerGroupId(@Nullable java.lang.String key)
CustomerGroupService
key
, this method first checks if a cached map of customer group keys -> ids
contains the key. If not, it returns a completed future that contains an Optional
that
contains what this key maps to in the cache. If the cache doesn't contain the key; this method
attempts to fetch the id of the key from the CTP project, caches it and returns a CompletionStage
<Optional
<String
>> in which the result of its
completion could contain an Optional
with the id inside of it or an empty Optional
if no CustomerGroup
was found in the CTP project with this key.fetchCachedCustomerGroupId
in interface CustomerGroupService
key
- the key by which a CustomerGroup
id should be fetched from the CTP project.CompletionStage
<Optional
<String
>> in which the
result of its completion could contain an Optional
with the id inside of it or an
empty Optional
if no CustomerGroup
was found in the CTP project with this
key or a blank (null/empty string) key was supplied.