Class CouchbaseCacheConfiguration
java.lang.Object
org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration
-
Method Summary
Modifier and TypeMethodDescriptioncollection
(String collectionName) Set the collectinName to use.computePrefixWith
(CacheKeyPrefix cacheKeyPrefix) Use the givenCacheKeyPrefix
to compute the prefix for the actual Couchbase key given the cache name as function input.static CouchbaseCacheConfiguration
Disable caching null values.entryExpiry
(Duration expiry) Set the expiry to apply for cache entries.boolean
The name of the collection to use for this cache - if empty uses the default collection.getKeyPrefixFor
(String cacheName) Get the computed key prefix for a given cacheName.com.couchbase.client.java.codec.Transcoder
Get the transcoder for encoding and decoding cache values.prefixCacheNameWith
(String prefix) Prefix thecache name
with the given value.static void
registerDefaultConverters
(ConverterRegistry registry) Registers default cache key converters.boolean
valueTranscoder
(com.couchbase.client.java.codec.Transcoder valueTranscoder) Sets a custom transcoder to use for reads and writes.
-
Method Details
-
defaultCacheConfig
-
registerDefaultConverters
Registers default cache key converters. The following converters get registered:- Parameters:
registry
- must not be null.
-
entryExpiry
Set the expiry to apply for cache entries. UseDuration.ZERO
to declare an eternal cache.- Parameters:
expiry
- must not be null.- Returns:
- new
CouchbaseCacheConfiguration
.
-
collection
Set the collectinName to use.- Parameters:
collectionName
- must not be null.- Returns:
- new
CouchbaseCacheConfiguration
.
-
valueTranscoder
public CouchbaseCacheConfiguration valueTranscoder(com.couchbase.client.java.codec.Transcoder valueTranscoder) Sets a custom transcoder to use for reads and writes.- Parameters:
valueTranscoder
- the transcoder that should be used.- Returns:
- new
CouchbaseCacheConfiguration
.
-
disableCachingNullValues
Disable caching null values.
NOTE anyCache.put(Object, Object)
operation involving null value will error. Nothing will be written to Couchbase, nothing will be removed. An already existing key will still be there afterwards with the very same value as before.- Returns:
- new
CouchbaseCacheConfiguration
.
-
prefixCacheNameWith
Prefix thecache name
with the given value.
The generated cache key will be:prefix + cache name + "::" + cache entry key
.- Parameters:
prefix
- the prefix to prepend to the cache name.- Returns:
- this.
- See Also:
-
computePrefixWith
Use the givenCacheKeyPrefix
to compute the prefix for the actual Couchbase key given the cache name as function input.- Parameters:
cacheKeyPrefix
- must not be null.- Returns:
- new
CouchbaseCacheConfiguration
. - See Also:
-
getExpiry
- Returns:
- The expiration time (ttl) for cache entries. Never null.
-
getAllowCacheNullValues
public boolean getAllowCacheNullValues()- Returns:
- true if caching null is allowed.
-
getConversionService
- Returns:
- The
ConversionService
used for cache key toString
conversion. Never null.
-
usePrefix
public boolean usePrefix()- Returns:
- true if cache keys need to be prefixed with the
getKeyPrefixFor(String)
if present or the default which resolves toCache.getName()
.
-
getKeyPrefixFor
Get the computed key prefix for a given cacheName.- Returns:
- never null.
-
getValueTranscoder
public com.couchbase.client.java.codec.Transcoder getValueTranscoder()Get the transcoder for encoding and decoding cache values. -
getCollectionName
The name of the collection to use for this cache - if empty uses the default collection.
-