Spring Data Couchbase

org.springframework.data.couchbase.cache
Class CouchbaseCache

java.lang.Object
  extended by org.springframework.data.couchbase.cache.CouchbaseCache
All Implemented Interfaces:
Cache

public class CouchbaseCache
extends Object
implements Cache

The CouchbaseCache class implements the Spring Cache interface on top of Couchbase Server and the Couchbase Java SDK.

Author:
Michael Nitschinger
See Also:
Official Spring Cache Reference

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.springframework.cache.Cache
Cache.ValueWrapper
 
Constructor Summary
CouchbaseCache(String name, com.couchbase.client.CouchbaseClient client)
          Construct the cache and pass in the CouchbaseClient instance.
 
Method Summary
 void clear()
          Clear the complete cache.
 void evict(Object key)
          Remove an object from Couchbase.
 Cache.ValueWrapper get(Object key)
          Get an element from the cache.
<T> T
get(Object key, Class<T> clazz)
           
 String getName()
          Returns the name of the cache.
 com.couchbase.client.CouchbaseClient getNativeCache()
          Returns the actual CouchbaseClient instance.
 void put(Object key, Object value)
          Store a object in Couchbase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CouchbaseCache

public CouchbaseCache(String name,
                      com.couchbase.client.CouchbaseClient client)
Construct the cache and pass in the CouchbaseClient instance.

Parameters:
name - the name of the cache reference.
client - the CouchbaseClient instance.
Method Detail

getName

public final String getName()
Returns the name of the cache.

Specified by:
getName in interface Cache
Returns:
the name of the cache.

getNativeCache

public final com.couchbase.client.CouchbaseClient getNativeCache()
Returns the actual CouchbaseClient instance.

Specified by:
getNativeCache in interface Cache
Returns:
the actual CouchbaseClient instance.

get

public final Cache.ValueWrapper get(Object key)
Get an element from the cache.

Specified by:
get in interface Cache
Parameters:
key - the key to lookup against.
Returns:
the fetched value from Couchbase.

get

public final <T> T get(Object key,
                       Class<T> clazz)

put

public final void put(Object key,
                      Object value)
Store a object in Couchbase.

Specified by:
put in interface Cache
Parameters:
key - the Key of the storable object.
value - the Object to store.

evict

public final void evict(Object key)
Remove an object from Couchbase.

Specified by:
evict in interface Cache
Parameters:
key - the Key of the object to delete.

clear

public final void clear()
Clear the complete cache. Note that this action is very destructive, so only use it with care. Also note that "flush" may not be enabled on the bucket.

Specified by:
clear in interface Cache

Spring Data Couchbase

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.