public class MemcachedCache extends Object
MemcachedRegionFactory
when generating cache keys.
All cache operations rely on using a KeyStrategy
to generate cache keys for use in memcached.
Support for the clear() operation is disabled by default.
There is no way for this instance of MemcachedCache to know what cache values to "clear" in a given Memcached instance.
Clear functionality is implemented by incrementing a "clearIndex" value that is always included in the cache-key generation.
When clear is called the memcached increment function is used to increment the global clean index. When clear is enabled,
every cache action taken starts with a call to memcached to 'get' the clearIndex counter. That value is then
applied to the cache key for the cache operation being taken. When the clearIndex is incremented this causes
the MemcachedCache to generate different cache-keys than it was before. This results in previously cached data being
abandoned in the cache, and left for memcached to deal with.
For these reasons it is not recommended to rely on clear() as a regular production functionality, it is very expensive and generally not very useful anyway.
The MemcachedCache treats Hibernate cache regions as namespaces in Memcached. For more information see the memcached FAQ.
| Modifier and Type | Field and Description |
|---|---|
static Integer |
DOGPILE_TOKEN |
| Constructor and Description |
|---|
MemcachedCache(String regionName,
Memcache memcachedClient,
Config config) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear functionality is disabled by default.
|
void |
destroy() |
Object |
get(Object key) |
int |
getCacheTimeSeconds() |
double |
getDogpilePreventionExpirationFactor() |
long |
getElementCountInMemory() |
long |
getElementCountOnDisk() |
KeyStrategy |
getKeyStrategy() |
String |
getRegionName() |
long |
getSizeInMemory() |
boolean |
isClearSupported() |
boolean |
isDogpilePreventionEnabled() |
void |
lock(Object key) |
void |
put(Object key,
Object value) |
Object |
read(Object key) |
void |
remove(Object key) |
void |
setCacheTimeSeconds(int cacheTimeSeconds) |
void |
setClearSupported(boolean clearSupported) |
void |
setDogpilePreventionEnabled(boolean dogpilePreventionEnabled) |
void |
setDogpilePreventionExpirationFactor(double dogpilePreventionExpirationFactor) |
void |
setKeyStrategy(KeyStrategy keyStrategy) |
Map<?,?> |
toMap() |
String |
toString() |
void |
unlock(Object key) |
void |
update(Object key,
Object value) |
public static final Integer DOGPILE_TOKEN
public int getCacheTimeSeconds()
public void setCacheTimeSeconds(int cacheTimeSeconds)
public boolean isClearSupported()
public void setClearSupported(boolean clearSupported)
public boolean isDogpilePreventionEnabled()
public void setDogpilePreventionEnabled(boolean dogpilePreventionEnabled)
public double getDogpilePreventionExpirationFactor()
public void setDogpilePreventionExpirationFactor(double dogpilePreventionExpirationFactor)
public Object read(Object key) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic Object get(Object key) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic void put(Object key, Object value) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic void update(Object key, Object value) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic void remove(Object key) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic void clear()
throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionMemcachedCachepublic void destroy()
throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic void lock(Object key) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic void unlock(Object key) throws org.hibernate.cache.CacheException
org.hibernate.cache.CacheExceptionpublic String getRegionName()
public long getSizeInMemory()
public long getElementCountInMemory()
public long getElementCountOnDisk()
public Map<?,?> toMap()
public KeyStrategy getKeyStrategy()
public void setKeyStrategy(KeyStrategy keyStrategy)
Copyright © 2017. All rights reserved.