public interface DistributedMap
extends java.util.Map
cache.instance.0=/services/cache/instance_one
cache.instance.0.cacheSize=1000
cache.instance.0.enableDiskOffload=true
cache.instance.0.diskOffloadLocation=${WAS_INSTALL_ROOT}/temp
cache.instance.1=/services/cache/instance_two
cache.instance.1.cacheSize=1500
cache.instance.1.enableDiskOffload=true
cache.instance.1.diskOffloadLocation=C:/disk
The distributedmap.properties file must be located in either you application
server or application's classpath.
The first entry in the properties file (cache.instance.0) specifies the JNDI
name for the cache instance in the global namespace. You could then lookup
the cache instance using the following code:
InitialContext ic = new InitialContext();
DistributedMap dm =(DistributedMap)ic.lookup("services/cache/instance_one");
Alternatively, you can define a resource-ref for in cache in your module's
deployement descriptor and then lookup the cache using the java:comp namespace.
dmap/LayoutCache
com.ibm.websphere.cache.DistributedMap
Container
Shareable
An example of looking up the resource-ref:
InitialContext ic = new InitialContext();
DistributedMap dm =(DistributedMap)ic.lookup("java:comp/env/dmap/LayoutCache");
Modifier and Type | Method and Description |
---|---|
void |
addAlias(java.lang.Object key,
java.lang.Object[] aliasArray)
Adds an alias for the given key in the cache's mapping table.
|
boolean |
addChangeListener(ChangeListener listener)
addChangeListener - adds a change listener for this DistributedMap.
|
boolean |
addInvalidationListener(InvalidationListener listener)
addInvalidationListener - adds an invalidation listener for this DistributeMap.
|
boolean |
containsKey(java.lang.Object key,
boolean includeDiskCache)
Returns true if this map contains mapping for the specified key.
|
boolean |
enableListener(boolean enable)
enableListener - enable or disable the invalidation and change listener support.
|
java.lang.Object |
get(java.lang.Object key)
Returns the value to which this map maps the specified key.
|
int |
getSharingPolicy()
getSharingPolicy - gets the sharing policy for DistributedMap.
|
void |
invalidate(java.lang.Object key)
invalidate - invalidates the given key.
|
void |
invalidate(java.lang.Object key,
boolean wait)
invalidate - invalidates the given key.
|
boolean |
isDRSBootstrapEnabled()
isDRSBootstrapEnabled - check whether DRS bootstrap for DistributedMap is enabled or not.
|
boolean |
isEmpty(boolean includeDiskCache)
Returns true if this map contains no key-value mappings.
|
java.util.Set |
keySet(boolean includeDiskCache)
Returns a set view of the keys contained in this map.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map
(optional operation).
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value,
int priority,
int timeToLive,
int inactivityTime,
int sharingPolicy,
java.lang.Object[] dependencyIds)
Associates the specified value with the specified key in this map
(optional operation).
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value,
int priority,
int timeToLive,
int sharingPolicy,
java.lang.Object[] dependencyIds)
Associates the specified value with the specified key in this map
(optional operation).
|
void |
removeAlias(java.lang.Object alias)
Removes an alias from the cache's mapping table.
|
boolean |
removeChangeListener(ChangeListener listener)
removeChangeListener - removes a change listener for this DistributedMap.
|
boolean |
removeInvalidationListener(InvalidationListener listener)
removeInvalidationListener - removes an invalidation listener for this DistributedMap.
|
void |
setDRSBootstrap(boolean drsBootstrap)
setDRSBootstrap - Enables or disbales DRS bootstrap support
|
void |
setPriority(int priority)
Sets the global priority for this map..
|
void |
setSharingPolicy(int sharingPolicy)
setSharingPolicy - sets the sharing policy for DistributedMap.
|
void |
setTimeToLive(int timeToLive)
Set the global time-to-live this this map.
|
int |
size(boolean includeDiskCache)
Returns the total number of key-value mappings.
|
void setSharingPolicy(int sharingPolicy)
sharingPolicy
- policy to set. Default is EntryInfo.NOT_SHAREDgetSharingPolicy()
int getSharingPolicy()
setSharingPolicy(int)
void setDRSBootstrap(boolean drsBootstrap)
drsBootstrap
- - true (default) to enable DRS bootstrap support,
or false to ignore DRS bootstrap messages for this cache instanceisDRSBootstrapEnabled()
boolean isDRSBootstrapEnabled()
setDRSBootstrap(boolean)
void setTimeToLive(int timeToLive)
timeToLive
- the time in seconds that cache entries should remain
in the cache. The default value is -1 and means the entry
does not time out.void setPriority(int priority)
priority
- the global priority value for the cache entries. entries
with higher priority will remain in the cache longer
than those with a lesser priority in the case of cache
overflow. Valid priorities are 1 through 16 with 1 being
the default value. 1 is the lowest priority and 16 is the highest.java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
key
- key whose associated value is to be returned.java.lang.ClassCastException
- if the key is not of an inappropriate type for
this map. (Currently supports only String)java.lang.NullPointerException
- key is null and this map does not
not permit null keys.Map.containsKey(Object)
java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.java.lang.UnsupportedOperationException
- if the put operation is
not supported by this map.java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.java.lang.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.java.lang.NullPointerException
- this map does not permit null
keys or values, and the specified key or value is
null.java.lang.Object put(java.lang.Object key, java.lang.Object value, int priority, int timeToLive, int sharingPolicy, java.lang.Object[] dependencyIds)
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.priority
- the priority value for the cache entry. entries
with higher priority will remain in the cache longer
than those with a lesser priority in the case of cache
overflow. Valid priorities are 1 through 16 with 1 being
the default value. 1 is the lowest priority and 16 is the highest.timeToLive
- the time in seconds that the cache entry should remain
in the cache. The default value is -1 and means the entry
does not time out.sharingPolicy
- how the cache entry should be shared in a cluster.
values are EntryInfo.NOT_SHARED, EntryInfo.SHARED_PUSH,
and EntryInfo.SHARED_PUSH_PULL.dependencyIds
- an optional set of dependency ids to associate with
the cache entryjava.lang.UnsupportedOperationException
- if the put operation is
not supported by this map.java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.java.lang.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.java.lang.NullPointerException
- this map does not permit null
keys or values, and the specified key or value is
null.java.lang.Object put(java.lang.Object key, java.lang.Object value, int priority, int timeToLive, int inactivityTime, int sharingPolicy, java.lang.Object[] dependencyIds)
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.priority
- the priority value for the cache entry. entries
with higher priority will remain in the cache longer
than those with a lesser priority in the case of cache
overflow. Valid priorities are 1 through 16 with 1 being
the default value. 1 is the lowest priority and 16 is the highest.timeToLive
- the time in seconds that the cache entry should remain
in the cache. The default value is -1 and means the entry
does not time out.inactivityTime
- the time in seconds that the cache entry should remain
in the cache if not accessed. This is reset once an entry is
accessed.sharingPolicy
- how the cache entry should be shared in a cluster.
values are EntryInfo.NOT_SHARED, EntryInfo.SHARED_PUSH,
EntryInfo.SHARED_PULL, and EntryInfo.SHARED_PUSH_PULLdependencyIds
- an optional set of dependency ids to associate with
the cache entryjava.lang.UnsupportedOperationException
- if the put operation is
not supported by this map.java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.java.lang.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.java.lang.NullPointerException
- this map does not permit null
keys or values, and the specified key or value is
null.void invalidate(java.lang.Object key)
key
- the key which will be invalidatedMap.remove(Object key)
void invalidate(java.lang.Object key, boolean wait)
key
- the key which will be invalidatedwait
- if true, then the method will not complete until the invalidation
has occured. if false, then the invalidation will occur in batch modeMap.remove(Object key)
boolean enableListener(boolean enable)
enable
- - true to enable support for invalidation and change listeners
or false to disable support for invalidation and change listenersboolean addInvalidationListener(InvalidationListener listener)
listener
- the invalidation listener objectremoveInvalidationListener(com.ibm.websphere.cache.InvalidationListener)
boolean removeInvalidationListener(InvalidationListener listener)
listener
- the invalidation listener objectaddInvalidationListener(com.ibm.websphere.cache.InvalidationListener)
boolean addChangeListener(ChangeListener listener)
listener
- the change listener objectremoveChangeListener(com.ibm.websphere.cache.ChangeListener)
boolean removeChangeListener(ChangeListener listener)
listener
- the change listener objectaddChangeListener(com.ibm.websphere.cache.ChangeListener)
void addAlias(java.lang.Object key, java.lang.Object[] aliasArray)
key
- the key assoicated with aliasaliasArray
- the alias to use for lookupsjava.lang.IllegalArgumentException
- if the key is not in the cache's mapping table.void removeAlias(java.lang.Object alias)
alias
- the alias to move out of the cache's mapping tableint size(boolean includeDiskCache)
includeDiskCache
- true to get the size of the memory and disk maps; false to get the size of memory map.boolean isEmpty(boolean includeDiskCache)
includeDiskCache
- true to check the memory and disk maps; false to check the memory map.boolean containsKey(java.lang.Object key, boolean includeDiskCache)
key
- whose presence in this map is to be tested.includeDiskCache
- true to check the specified key contained in the memory or disk maps; false to check the specified key contained in the memory map.java.util.Set keySet(boolean includeDiskCache)
includeDiskCache
- true to get keys contained in the memory and disk maps; false to get keys contained in the memory map.