Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class ClusteredCache

java.lang.Object
  extended by com.jivesoftware.util.ClusteredCache
All Implemented Interfaces:
Cache, com.tangosol.util.InvocableMap, com.tangosol.util.QueryMap, java.util.Map

public class ClusteredCache
extends java.lang.Object
implements Cache, com.tangosol.util.QueryMap, com.tangosol.util.InvocableMap

Clustered implementation of the Cache interface using Tangosol's Coherence product. For handling RequestTimeoutExceptions with Coherence 3.3, the strategy is to log and throw the exceptions for puts and removes. Gets can fail gracefully since content will be pulled from the database.


Nested Class Summary
static class ClusteredCache.CacheCollectionWrapper
           
static class ClusteredCache.CacheIterator
           
static class ClusteredCache.CacheSetWrapper
           
 
Nested classes/interfaces inherited from interface com.tangosol.util.QueryMap
com.tangosol.util.QueryMap.Entry
 
Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap
com.tangosol.util.InvocableMap.Entry, com.tangosol.util.InvocableMap.EntryAggregator, com.tangosol.util.InvocableMap.EntryProcessor, com.tangosol.util.InvocableMap.ParallelAwareAggregator
 
Field Summary
protected  com.tangosol.net.NamedCache map
          The map is used for distributed operations such as get, put, etc.
 
Constructor Summary
protected ClusteredCache(java.lang.String name)
          Create a new cache.
protected ClusteredCache(java.lang.String name, com.tangosol.net.NamedCache cache)
          Create a new cache using the supplied named cache as the actual cache implementation
 
Method Summary
 void addIndex(com.tangosol.util.ValueExtractor valueExtractor, boolean sorted, java.util.Comparator comparator)
           
 void addMemberListener(com.tangosol.net.MemberListener listener)
           
 java.lang.Object aggregate(java.util.Collection collection, com.tangosol.util.InvocableMap.EntryAggregator entryAggregator)
           
 java.lang.Object aggregate(com.tangosol.util.Filter filter, com.tangosol.util.InvocableMap.EntryAggregator entryAggregator)
           
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 java.util.Set entrySet(com.tangosol.util.Filter filter)
           
 java.util.Set entrySet(com.tangosol.util.Filter filter, java.util.Comparator comparator)
           
 java.lang.Object get(java.lang.Object key)
           
 long getCacheHits()
          Returns the number of cache hits.
 long getCacheMisses()
          Returns the number of cache misses.
 int getCacheSize()
          Returns the size of the cache contents in bytes.
 int getMaxCacheSize()
          Returns the maximum size of the cache in bytes.
 long getMaxLifetime()
          Returns the maximum number of milliseconds that any object can live in cache.
 java.lang.String getName()
          Returns the name of the cache.
 java.lang.Object invoke(java.lang.Object object, com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
           
 java.util.Map invokeAll(java.util.Collection collection, com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
           
 java.util.Map invokeAll(com.tangosol.util.Filter filter, com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
           
 boolean isEmpty()
           
 java.util.Set keySet()
           
 java.util.Set keySet(com.tangosol.util.Filter filter)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object object)
           
 void putAll(java.util.Map entries)
           
 java.lang.Object remove(java.lang.Object key)
           
 void removeIndex(com.tangosol.util.ValueExtractor valueExtractor)
           
 void removeMemberListener(com.tangosol.net.MemberListener listener)
           
 void setMaxCacheSize(int maxSize)
          Sets the maximum size of the cache in bytes.
 void setMaxLifetime(long maxLifetime)
          Sets the maximum number of milliseconds that any object can live in cache.
 void setName(java.lang.String name)
          Sets the name of the cache
 int size()
           
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 
Methods inherited from interface java.util.Map
equals, hashCode
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

map

protected com.tangosol.net.NamedCache map
The map is used for distributed operations such as get, put, etc.

Constructor Detail

ClusteredCache

protected ClusteredCache(java.lang.String name)
Create a new cache.

Parameters:
name - a name for the cache, which should be unique per vm.

ClusteredCache

protected ClusteredCache(java.lang.String name,
                         com.tangosol.net.NamedCache cache)
Create a new cache using the supplied named cache as the actual cache implementation

Parameters:
name - a name for the cache, which should be unique per vm.
cache - the cache implementation
Method Detail

addMemberListener

public void addMemberListener(com.tangosol.net.MemberListener listener)

removeMemberListener

public void removeMemberListener(com.tangosol.net.MemberListener listener)

getName

public java.lang.String getName()
Description copied from interface: Cache
Returns the name of the cache.

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

setName

public void setName(java.lang.String name)
Description copied from interface: Cache
Sets the name of the cache

Specified by:
setName in interface Cache
Parameters:
name - the name of the cache

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object object)
Specified by:
put in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

clear

public void clear()
Specified by:
clear in interface java.util.Map

size

public int size()
Specified by:
size in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

putAll

public void putAll(java.util.Map entries)
Specified by:
putAll in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

getCacheHits

public long getCacheHits()
Description copied from interface: Cache
Returns the number of cache hits. A cache hit occurs every time the get method is called and the cache contains the requested object.

Keeping track of cache hits and misses lets one measure how efficient the cache is; the higher the percentage of hits, the more efficient.

Specified by:
getCacheHits in interface Cache
Returns:
the number of cache hits.

getCacheMisses

public long getCacheMisses()
Description copied from interface: Cache
Returns the number of cache misses. A cache miss occurs every time the get method is called and the cache does not contain the requested object.

Keeping track of cache hits and misses lets one measure how efficient the cache is; the higher the percentage of hits, the more efficient.

Specified by:
getCacheMisses in interface Cache
Returns:
the number of cache hits.

getCacheSize

public int getCacheSize()
Description copied from interface: Cache
Returns the size of the cache contents in bytes. This value is only a rough approximation, so cache users should expect that actual VM memory used by the cache could be significantly higher than the value reported by this method.

Specified by:
getCacheSize in interface Cache
Returns:
the size of the cache contents in bytes.

getMaxCacheSize

public int getMaxCacheSize()
Description copied from interface: Cache
Returns the maximum size of the cache in bytes. If the cache grows larger than the max size, the least frequently used items will be removed. If the max cache size is set to -1, there is no size limit.

Specified by:
getMaxCacheSize in interface Cache
Returns:
the maximum size of the cache in bytes.

setMaxCacheSize

public void setMaxCacheSize(int maxSize)
Description copied from interface: Cache
Sets the maximum size of the cache in bytes. If the cache grows larger than the max size, the least frequently used items will be removed. If the max cache size is set to -1, there is no size limit.

Specified by:
setMaxCacheSize in interface Cache
Parameters:
maxSize - the maximum size of the cache in bytes.

getMaxLifetime

public long getMaxLifetime()
Description copied from interface: Cache
Returns the maximum number of milliseconds that any object can live in cache. Once the specified number of milliseconds passes, the object will be automatically expried from cache. If the max lifetime is set to -1, then objects never expire.

Specified by:
getMaxLifetime in interface Cache
Returns:
the maximum number of milliseconds before objects are expired.

setMaxLifetime

public void setMaxLifetime(long maxLifetime)
Description copied from interface: Cache
Sets the maximum number of milliseconds that any object can live in cache. Once the specified number of milliseconds passes, the object will be automatically expried from cache. If the max lifetime is set to -1, then objects never expire.

Specified by:
setMaxLifetime in interface Cache
Parameters:
maxLifetime - the maximum number of milliseconds before objects are expired.

invoke

public java.lang.Object invoke(java.lang.Object object,
                               com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
Specified by:
invoke in interface com.tangosol.util.InvocableMap

invokeAll

public java.util.Map invokeAll(java.util.Collection collection,
                               com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
Specified by:
invokeAll in interface com.tangosol.util.InvocableMap

invokeAll

public java.util.Map invokeAll(com.tangosol.util.Filter filter,
                               com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
Specified by:
invokeAll in interface com.tangosol.util.InvocableMap

aggregate

public java.lang.Object aggregate(java.util.Collection collection,
                                  com.tangosol.util.InvocableMap.EntryAggregator entryAggregator)
Specified by:
aggregate in interface com.tangosol.util.InvocableMap

aggregate

public java.lang.Object aggregate(com.tangosol.util.Filter filter,
                                  com.tangosol.util.InvocableMap.EntryAggregator entryAggregator)
Specified by:
aggregate in interface com.tangosol.util.InvocableMap

keySet

public java.util.Set keySet(com.tangosol.util.Filter filter)
Specified by:
keySet in interface com.tangosol.util.QueryMap

entrySet

public java.util.Set entrySet(com.tangosol.util.Filter filter)
Specified by:
entrySet in interface com.tangosol.util.QueryMap

entrySet

public java.util.Set entrySet(com.tangosol.util.Filter filter,
                              java.util.Comparator comparator)
Specified by:
entrySet in interface com.tangosol.util.QueryMap

addIndex

public void addIndex(com.tangosol.util.ValueExtractor valueExtractor,
                     boolean sorted,
                     java.util.Comparator comparator)
Specified by:
addIndex in interface com.tangosol.util.QueryMap

removeIndex

public void removeIndex(com.tangosol.util.ValueExtractor valueExtractor)
Specified by:
removeIndex in interface com.tangosol.util.QueryMap

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.