IBM WebSphereTM eXtreme Scale, Release 8.5
API Specification

com.ibm.websphere.objectgrid.spring
Class ObjectGridCache

java.lang.Object
  extended by com.ibm.websphere.objectgrid.spring.ObjectGridCache
All Implemented Interfaces:
InitializingBean, Cache

public final class ObjectGridCache
extends Object
implements Cache, InitializingBean

This class is a WebSphere eXtreme Scale implementation of the Spring Framework's Cache interface.

Users must provide a name and a ObjectGridClientBean to configure this cache. The ObjectMap name is optional when using the provided XML configuration files.

This implementation allows for the storage of null values and does not support null keys.

The following Spring Inversion of Control (IoC) container configuration snippet creates two caches, named default and books hosted by the catalog service domain with connection end-points of host1:2809,host2:2809.

 <bean id="wxsCSDomain" class="com.ibm.websphere.objectgrid.spring.ObjectGridCatalogServiceDomainBean"
     p:catalog-service-endpoints="host1:2809,host2:2809" />
       
 <bean id="wxsGridClient" class="com.ibm.websphere.objectgrid.spring.ObjectGridClientBean"  
      p:catalog-service-domain-ref="wxsCSDomain" />
        
 <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
     <property name="caches">
         <set>
             <bean class="com.ibm.websphere.objectgrid.spring.ObjectGridCache" 
                 p:name="default" 
                 p:object-grid-client-ref="wxsGridClient" />
             <bean class="com.ibm.websphere.objectgrid.spring.ObjectGridCache" 
                 p:name="books" 
                 p:object-grid-client-ref="wxsGridClient" />
         </set>
     </property>
 </bean>
 

Since:
8.5, XC10

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.springframework.cache.Cache
Cache.ValueWrapper
 
Constructor Summary
ObjectGridCache()
           
 
Method Summary
 void afterPropertiesSet()
          Initializes this cache.
 void clear()
          Clears all entries from the cache.
 void evict(Object key)
          Evicts the entry at the given key.
 Cache.ValueWrapper get(Object key)
          Retrieves the object from the cache at the given key.
 String getName()
          Returns the name of the cache.
 Object getNativeCache()
          This implementation returns null.
 void put(Object key, Object value)
          Creates an entry in the cache.
 void setMapName(String mapName)
          Sets the ObjectMap name.
 void setName(String name)
          Sets the cache name.
 void setObjectGridClient(ObjectGridClientBean objectGridClient)
          Sets the ObjectGridClientBean to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectGridCache

public ObjectGridCache()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Initializes this cache. This method is to be called after all setter methods have been called and will throw an IllegalArgumentException if setObjectGridClient(ObjectGridClientBean) or setName(String) have not been called prior.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception - if setObjectGridClient(ObjectGridClientBean) or setName(String) have not been called prior or an error occurs initializing the cache.
See Also:
InitializingBean.afterPropertiesSet()

getName

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

Specified by:
getName in interface Cache
Returns:
The name of the cache.
See Also:
Cache.getName()

setName

public void setName(String name)
Sets the cache name.

Parameters:
name - The cache name.
See Also:
getName()

setMapName

public void setMapName(String mapName)
Sets the ObjectMap name. This is optional when using the provided XML configuration files.

Parameters:
mapName - The name of the ObjectMap

setObjectGridClient

public void setObjectGridClient(ObjectGridClientBean objectGridClient)
Sets the ObjectGridClientBean to use.

Parameters:
objectGridClient - The ObjectGridClientBean to use

getNativeCache

public Object getNativeCache()
This implementation returns null.

Specified by:
getNativeCache in interface Cache
Returns:
This implementation returns null.
See Also:
Cache.getNativeCache()

get

public Cache.ValueWrapper get(Object key)
Retrieves the object from the cache at the given key. Returns null if there is no mapping for the key or if the key is null

Specified by:
get in interface Cache
Returns:
the object from the cache at the given key or null if there is no mapping or the key is null
See Also:
Cache.get(java.lang.Object)

put

public void put(Object key,
                Object value)
Creates an entry in the cache. Overwrites the value if an entry for the given key exists. This method does not create an entry if the given key is null.

Specified by:
put in interface Cache
See Also:
Cache.put(java.lang.Object, java.lang.Object)

evict

public void evict(Object key)
Evicts the entry at the given key. If the provided key is null this method does not evict any entries.

Specified by:
evict in interface Cache
See Also:
Cache.evict(java.lang.Object)

clear

public void clear()
Clears all entries from the cache.

Specified by:
clear in interface Cache
See Also:
Cache.clear()

IBM WebSphereTM eXtreme Scale, Release 8.5
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.