Class DefaultCouchbaseCacheWriter
java.lang.Object
org.springframework.data.couchbase.cache.DefaultCouchbaseCacheWriter
- All Implemented Interfaces:
CouchbaseCacheWriter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongClears the cache with the given key pattern prefix.Get the binary value representation from Couchbase stored for the given key.get(String collectionName, String key, com.couchbase.client.java.codec.Transcoder transcoder, Class<?> clazz) Get the binary value representation from Couchbase stored for the given key.voidput(String collectionName, String key, Object value, Duration expiry, com.couchbase.client.java.codec.Transcoder transcoder) Write the given key/value pair to Couchbase an set the expiration time if defined.putIfAbsent(String collectionName, String key, Object value, Duration expiry, com.couchbase.client.java.codec.Transcoder transcoder) Write the given value to Couchbase if the key does not already exist.putIfAbsent(String collectionName, String key, Object value, Duration expiry, com.couchbase.client.java.codec.Transcoder transcoder, Class<?> clazz) same as above, plus clazzbooleanRemove the given key from Couchbase.
-
Constructor Details
-
DefaultCouchbaseCacheWriter
-
-
Method Details
-
put
public void put(String collectionName, String key, Object value, Duration expiry, com.couchbase.client.java.codec.Transcoder transcoder) Description copied from interface:CouchbaseCacheWriterWrite the given key/value pair to Couchbase an set the expiration time if defined.- Specified by:
putin interfaceCouchbaseCacheWriter- Parameters:
collectionName- The cache name must not be null.key- The key for the cache entry. Must not be null.value- The value stored for the key. Must not be null.expiry- Optional expiration time. Can be null.transcoder- Optional transcoder to use. Can be null.
-
putIfAbsent
public Object putIfAbsent(String collectionName, String key, Object value, Duration expiry, com.couchbase.client.java.codec.Transcoder transcoder) Description copied from interface:CouchbaseCacheWriterWrite the given value to Couchbase if the key does not already exist.- Specified by:
putIfAbsentin interfaceCouchbaseCacheWriter- Parameters:
collectionName- The cache name must not be null.key- The key for the cache entry. Must not be null.value- The value stored for the key. Must not be null.expiry- Optional expiration time. Can be null.transcoder- Optional transcoder to use. Can be null.
-
putIfAbsent
public Object putIfAbsent(String collectionName, String key, Object value, Duration expiry, com.couchbase.client.java.codec.Transcoder transcoder, @Nullable Class<?> clazz) same as above, plus clazz- Specified by:
putIfAbsentin interfaceCouchbaseCacheWriter- Parameters:
collectionName-key-value-expiry-transcoder-clazz-
-
get
public Object get(String collectionName, String key, com.couchbase.client.java.codec.Transcoder transcoder) Description copied from interface:CouchbaseCacheWriterGet the binary value representation from Couchbase stored for the given key.- Specified by:
getin interfaceCouchbaseCacheWriter- Parameters:
collectionName- must not be null.key- must not be null.transcoder- Optional transcoder to use. Can be null.- Returns:
- null if key does not exist.
-
get
public Object get(String collectionName, String key, com.couchbase.client.java.codec.Transcoder transcoder, Class<?> clazz) Description copied from interface:CouchbaseCacheWriterGet the binary value representation from Couchbase stored for the given key.- Specified by:
getin interfaceCouchbaseCacheWriter- Parameters:
collectionName- must not be null.key- must not be null.transcoder- Optional transcoder to use. Can be null.clazz- Optional class for contentAs(clazz)- Returns:
- null if key does not exist.
-
remove
Description copied from interface:CouchbaseCacheWriterRemove the given key from Couchbase.- Specified by:
removein interfaceCouchbaseCacheWriter- Parameters:
collectionName- The cache name must not be null.key- The key for the cache entry. Must not be null.- Returns:
- true if the document existed on removal, false otherwise.
-
clear
Description copied from interface:CouchbaseCacheWriterClears the cache with the given key pattern prefix.- Specified by:
clearin interfaceCouchbaseCacheWriterpattern- the pattern to clear.- Returns:
- the number of cleared items.
-