public abstract class AbstractMemcached<K,V> extends AbstractNurseryService implements Cache<K,V>
GenericService.StartCommand, GenericService.StopCommand
CLASS_VERSION
mLogger, state
Constructor and Description |
---|
AbstractMemcached() |
Modifier and Type | Method and Description |
---|---|
void |
addObject(K pKey,
V pValue)
Add a new object to the cache.
|
protected abstract Cache<K,V> |
createCache() |
void |
expireObject(K pKey)
Expire an object in the cache.
|
void |
flushCache()
This method will flush all objects from the cache.
|
String |
getCacheType() |
Iterable<K> |
getKeys()
Returns all the keys in the cache
|
int |
getMaxSize()
Get the max number of cached objects in this cache.
|
V |
getObject(K pKey)
Get an object from the cache.
|
String |
getPrefix() |
String |
getReport(String type)
Return a report for this status
|
int |
getSize()
Returns the current size of the cache.
|
Number |
getStatistic(String pStatisticKey)
The different statistics metrics of the implementing class.
|
Set |
getStatisticKeys()
The keys that the metrics are available under.
|
int |
getValidSeconds()
Valid seconds is not supported for MemCached enabled caches.
|
boolean |
hasObject(K pKey)
Check if the cache contains the object while not changing any of
the cache statistics.
|
void |
remove(CacheFilter<K,V> pFilter)
Iterates through all the items in the cache and removes all items that is not accepted by the given filter.
|
void |
reset()
Reset any counters
|
void |
setMaxSize(int pMaxSize) |
void |
setPrefix(String pPrefix) |
protected void |
startService()
Is called by
AbstractNurseryService.doStartService() when the NurseryService is being started. |
protected void |
stopService()
Is called by
AbstractNurseryService.doStopService() when the service is being shut down. |
String |
toString() |
doStartService, doStopService, stopIdleService
assertServiceRunning, getServiceDescription, getServiceMessage, getServiceState, isServiceEnabled, isServiceFailed, isServiceIdle, isServiceRunning, isServiceShutdownFailed, isServiceStopped, setServiceDescription, setServiceEnabled, start, stop, validateIsTrue, validateNotNull
protected void startService() throws Exception
AbstractNurseryService
Is called by AbstractNurseryService.doStartService()
when the NurseryService
is being started. Exceptions thrown by this
method are logged by AbstractNurseryService.doStartService()
.
Subclasses must implement this method to bootstrap the service.
startService
in class AbstractNurseryService
Exception
- when something goes wrong during startup. GenericService.isServiceRunning()
will return false
and GenericService.isServiceFailed()
will return true
.IllegalArgumentException
- when the configuration of the service
is invalid. GenericService.isServiceRunning()
will return false
and GenericService.isServiceFailed()
will return true
.IllegalStateException
- when this service is in the wrong state for startup. Used to signal to AbstractNurseryService.doStartService()
that it is OK to try to starting
this service
later. GenericService.isServiceRunning()
returns false
and GenericService.isServiceIdle()
returns true
.AbstractNurseryService.doStartService()
protected void stopService() throws Exception
AbstractNurseryService
Is called by AbstractNurseryService.doStopService()
when the service
is being shut down. Exceptions thrown by this
method are logged by AbstractNurseryService.doStopService()
.
Subclasses must implement this method to shut down the service.
stopService
in class AbstractNurseryService
IllegalStateException
- when this service is in the wrong state for shutdown. Used to signal to AbstractNurseryService.doStopService()
that
it is OK to try stopping this service
later. GenericService.isServiceRunning()
returns true
.Exception
- when something goes during shutdown. GenericService.isServiceRunning()
returns false
and
GenericService.isServiceShutdownFailed()
returns true
.AbstractNurseryService.doStopService()
public void setMaxSize(int pMaxSize)
public void setPrefix(String pPrefix)
public String getPrefix()
public String getCacheType()
getCacheType
in interface Cache<K,V>
public int getMaxSize()
Cache
getMaxSize
in interface Cache<K,V>
public final int getValidSeconds()
-1
getValidSeconds
in interface Cache<K,V>
public V getObject(K pKey)
Cache
public boolean hasObject(K pKey)
Cache
public void addObject(K pKey, V pValue)
Cache
public void expireObject(K pKey)
Cache
expireObject
in interface Cache<K,V>
pKey
- The identifier of the object to expire.public void flushCache()
Cache
flushCache
in interface Cache<K,V>
public int getSize()
Cache
getMaxSize
public Iterable<K> getKeys()
Cache
public Number getStatistic(String pStatisticKey)
StatisticsSource
getStatistic
in interface StatisticsSource
pStatisticKey
- the key of the metric wanted. See StatisticsSource.getStatisticKeys()
for a list of valid keys.StatisticsSource.getStatisticKeys()
public Set getStatisticKeys()
StatisticsSource
getStatisticKeys
in interface StatisticsSource
Set
of String
keys. It will
contain at least one key.StatisticsSource.getStatistic(String)
public String getReport(String type)
StatusSource
getReport
in interface StatusSource
public void reset()
StatusSource
reset
in interface StatusSource
public void remove(CacheFilter<K,V> pFilter)
Cache
© 1998- 2021 Escenic AS