Class DefaultCouchbaseCacheWriter

java.lang.Object
org.springframework.data.couchbase.cache.DefaultCouchbaseCacheWriter
All Implemented Interfaces:
CouchbaseCacheWriter

public class DefaultCouchbaseCacheWriter extends Object implements CouchbaseCacheWriter
  • Constructor Details

  • 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: CouchbaseCacheWriter
      Write the given key/value pair to Couchbase an set the expiration time if defined.
      Specified by:
      put in interface CouchbaseCacheWriter
      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: CouchbaseCacheWriter
      Write the given value to Couchbase if the key does not already exist.
      Specified by:
      putIfAbsent in interface CouchbaseCacheWriter
      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.
    • get

      public Object get(String collectionName, String key, com.couchbase.client.java.codec.Transcoder transcoder)
      Description copied from interface: CouchbaseCacheWriter
      Get the binary value representation from Couchbase stored for the given key.
      Specified by:
      get in interface CouchbaseCacheWriter
      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.
    • remove

      public boolean remove(String collectionName, String key)
      Description copied from interface: CouchbaseCacheWriter
      Remove the given key from Couchbase.
      Specified by:
      remove in interface CouchbaseCacheWriter
      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

      public long clear(String pattern)
      Description copied from interface: CouchbaseCacheWriter
      Clears the cache with the given key pattern prefix.
      Specified by:
      clear in interface CouchbaseCacheWriter
      Parameters:
      pattern - the pattern to clear.
      Returns:
      the number of cleared items.