Interface CouchbaseCacheWriter
- All Known Implementing Classes:
DefaultCouchbaseCacheWriter
public interface CouchbaseCacheWriter
-
Method Summary
Modifier and TypeMethodDescriptionlong
Clears the cache with the given key pattern prefix.@Nullable Object
get
(String collectionName, String key, @Nullable com.couchbase.client.java.codec.Transcoder transcoder) Get the binary value representation from Couchbase stored for the given key.@Nullable Object
get
(String collectionName, String key, @Nullable com.couchbase.client.java.codec.Transcoder transcoder, @Nullable Class<?> clazz) Get the binary value representation from Couchbase stored for the given key.void
put
(String collectionName, String key, Object value, @Nullable Duration expiry, @Nullable com.couchbase.client.java.codec.Transcoder transcoder) Write the given key/value pair to Couchbase an set the expiration time if defined.@Nullable Object
putIfAbsent
(String collectionName, String key, Object value, @Nullable Duration expiry, @Nullable com.couchbase.client.java.codec.Transcoder transcoder) Write the given value to Couchbase if the key does not already exist.@Nullable Object
putIfAbsent
(String collectionName, String key, Object value, @Nullable Duration expiry, @Nullable com.couchbase.client.java.codec.Transcoder transcoder, @Nullable Class<?> clazz) Write the given value to Couchbase if the key does not already exist.boolean
Remove the given key from Couchbase.
-
Method Details
-
put
void put(String collectionName, String key, Object value, @Nullable Duration expiry, @Nullable com.couchbase.client.java.codec.Transcoder transcoder) Write the given key/value pair to Couchbase an set the expiration time if defined.- 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
@Nullable Object putIfAbsent(String collectionName, String key, Object value, @Nullable Duration expiry, @Nullable com.couchbase.client.java.codec.Transcoder transcoder) Write the given value to Couchbase if the key does not already exist.- 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
@Nullable Object putIfAbsent(String collectionName, String key, Object value, @Nullable Duration expiry, @Nullable com.couchbase.client.java.codec.Transcoder transcoder, @Nullable Class<?> clazz) Write the given value to Couchbase if the key does not already exist.- 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.clazz
- Optional class for contentAs(clazz)
-
get
@Nullable Object get(String collectionName, String key, @Nullable com.couchbase.client.java.codec.Transcoder transcoder) Get the binary value representation from Couchbase stored for the given key.- 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
@Nullable Object get(String collectionName, String key, @Nullable com.couchbase.client.java.codec.Transcoder transcoder, @Nullable Class<?> clazz) Get the binary value representation from Couchbase stored for the given key.- 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
Remove the given key from Couchbase.- 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
Clears the cache with the given key pattern prefix.- Parameters:
pattern
- the pattern to clear.- Returns:
- the number of cleared items.
-