java.lang.Object | |
↳ | com.microstrategy.utils.cache.CacheBase |
![]() |
![]() |
Base class for caches.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DEFAULT_FILE_REFRESH_TIME | Refresh time constant indicating that default file refreshing time from the CacheRegistry shall be used for this cache. | |||||||||
int | DEFAULT_REFRESH_TIME | Refresh time constant indicating that default refresh time from the CacheRegistry shall be used for this cache. | |||||||||
int | DEFAULT_STATISTIC_TIME | Statistic time constant indicating that default statistic time from the CacheRegistry shall be used for this cache. | |||||||||
int | DEFAULT_SYS_TIMEOUT | ||||||||||
int | DEFAULT_USER_TIMEOUT | Timeout constant indicating that default timeout value from the CacheRegistry shall be used for this cache. | |||||||||
int | NO_REFRESH | Refresh time constant indicating that cache members are never automatically reloaded. | |||||||||
int | NO_STATISTIC | Statistic time constant indicating that cache shall not automatically log statistic. | |||||||||
int | NO_TIMEOUT | Timeout constant indicating that cache members shall never timeout. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static final Object | NO_KEY | This constant is returned from |
|||||||||
public String | alias | Cache alias. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CacheBase(String pName, boolean useSoftReferences, int pTimeout, int pRefreshTime)
Constructs a cache with specified name and soft reference flag.
| |||||||||||
CacheBase(String pName, boolean useSoftReferences, int pTimeout, int pRefreshTime, String pAlias) |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
synchronized void |
clear()
Clears the cache - all entries are removed.
| ||||||||||
void |
close()
Un-register cache from the cache registry.
| ||||||||||
boolean | contains(CacheHint hint) | ||||||||||
void |
delete(CacheHint hint)
Removes object from the cache and persistent storage
| ||||||||||
Object |
get(CacheHint hint)
Finds and returns cached object based on the hint.
| ||||||||||
String |
getName()
Returns cache name.
| ||||||||||
synchronized int |
getRefreshTime()
Returns cache refresh time in seconds.
| ||||||||||
synchronized int |
getStatisticTime()
Returns the statistic frequency in seconds.
| ||||||||||
synchronized int |
getTimeout()
Returns cache timeout in seconds.
| ||||||||||
void |
logStatistic()
Writes cache statistic message to the log.
| ||||||||||
void |
onHintClose(CacheHint hint)
This method is supposed to be called by the hint object when it is closed.
| ||||||||||
void |
put(CacheHint hint, Object ob)
Puts the object in the cache.
| ||||||||||
Object |
refresh(CacheHint hint)
Re-loads object from the persistent storage
| ||||||||||
void |
remove(CacheHint hint)
Removes an object from the cache.
| ||||||||||
void |
save(CacheHint hint, Object ob)
Puts the object in the cache and stores it in the memory.
| ||||||||||
synchronized void |
setRefreshTime(int value)
Sets cache refresh time in seconds.
| ||||||||||
synchronized void |
setStatisticTime(int value)
Sets the statistic frequency in seconds.
| ||||||||||
synchronized void |
setTimeout(int value)
Sets cache timeout in seconds.
| ||||||||||
synchronized int |
size()
Returns cache size.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
canUpdate(CacheHint hint)
Overridable.
| ||||||||||
synchronized void | configure(Properties prop) | ||||||||||
abstract Object |
getKey(CacheHint hint)
Overridable.
| ||||||||||
abstract Object |
load(CacheHint hint)
Overridable.
| ||||||||||
void |
onTimer()
This method is periodically called by the cache registry.
| ||||||||||
Object |
reLoad(CacheHint hint, Object ob)
Overridable.
| ||||||||||
void |
store(CacheHint hint, Object ob)
Overridable.
| ||||||||||
void |
unLoad(CacheHint hint)
Overridable.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Refresh time constant indicating that default file refreshing time from the CacheRegistry shall be used for this cache.
Refresh time constant indicating that default refresh time from the CacheRegistry shall be used for this cache.
Statistic time constant indicating that default statistic time from the CacheRegistry shall be used for this cache.
Timeout constant indicating that default timeout value from the CacheRegistry shall be used for this cache.
Refresh time constant indicating that cache members are never automatically reloaded.
Statistic time constant indicating that cache shall not automatically log statistic.
Timeout constant indicating that cache members shall never timeout.
This constant is returned from getKey(CacheHint)
if the hint object
does not contain enough information to build the key but it is still
possible to load the object from the persistent storage. For example,
if the WebIServerSession object contains the session ID, but does not
contain either server or project name makes it impossible to cache the
corresponding project-level objects but it is possible to load them.
Whenever the cache receives this constant it will always invoke
load(CacheHint)
, i.e. effectively bypassing the cache.
Cache alias. Short version of name, used for things like state persistence. Must be unique within application.
Constructs a cache with specified name and soft reference flag.
pName | cache name |
---|---|
useSoftReferences | controls whether hard or soft references shall be used between proxies and cached objects. |
IllegalArgumentException | if the cache with specified name already exosts/ |
---|
IllegalArgumentException |
---|
Un-register cache from the cache registry. Cache shall not be used after this call.
Removes object from the cache and persistent storage
hint | the hint object. |
---|
CacheException |
---|
Finds and returns cached object based on the hint. If object does not exists in the memory it will be loaded from the persistent memory. Returns null if object does not exists in persistent memory either.
hint | the hint object. |
---|
CacheException |
---|
Returns cache name.
Returns cache refresh time in seconds. This property determines the time interval between consecutive automatic re-loads of cached objects.
Returns the statistic frequency in seconds.
Returns cache timeout in seconds. This property determines for how long cached object can remain in memory without being used.
Writes cache statistic message to the log. The message level is INFO. It contains the following information:
Get count | - | Total number of get requests processed by the cache. |
Load count | - | Total number of load/reload operations performed by the cache. |
Hit rate | - | The percentage of get requests satisfied from the memory to all get requests |
GC Count | - | Total number of soft-referenced cached objects removed by the Garbage Collector |
GC rate | - | The percentage of load/reload operations caused by the GC to all load/reload operations |
This method is supposed to be called by the hint object when it is closed. Cache implementations shall use this call to perform proper cache cleanup.
hint | the hint object. |
---|
Puts the object in the cache. If cache already contains object corresponding to the specified hint it will be replaced with the new one.
hint | the hint object. |
---|---|
ob | object to be cached |
CacheException |
---|
Re-loads object from the persistent storage
hint | the hint object. |
---|
CacheException |
---|
Puts the object in the cache and stores it in the memory. Normally this method will be called after application obtained an object from the cache and modified it. But it is also possible to use this method to replace cached object with another one or to add to the cache and to the persistent storage a new object.
hint | the hint object. |
---|---|
ob | object to be cached |
CacheException |
---|
Sets cache refresh time in seconds. This property determins time interval between consequtive automatic re-loads of cached objects.
value | refresh time in seconds. |
---|
Sets the statistic frequency in seconds. Notice that because the statistic is logged during onTimer event it will never be logged more often then CacheRegistry.cleanupTime value regardless of this property value.
value | log frequency in seconds. |
---|
Sets cache timeout in seconds. This property determines for how long cached object can remain in memory without being used.
value | timeout in seconds. |
---|
Returns cache size.
Overridable. Returns true if the hint allows updates. Default implementation always returns true.
hint | the hint object. |
---|
CacheException |
---|
Overridable. Extracts from the hint object the key that shall be used to identify the cached object.
hint | the hint object. |
---|
CacheException | if somethig gos wrong. |
---|
Overridable. Creates a new cached object instance and populates it with data from the persistent storage. In case the object not found in the persistent storage the implementation can return either null or a dummy object.
hint | the hint object. |
---|
CacheException | if somethig gos wrong. |
---|
This method is periodically called by the cache registry. It loops through cached objects and removes not-used ones.
Overridable. Re-populates cached object with data from persistent storage. Implementation of this method can re-load the object “in-place” or it can create another object.
hint | the hint object. |
---|
CacheException | if somethig gos wrong. |
---|
Overridable. Saves cached object in the persistent storage.
hint | the hint object. |
---|---|
ob | the object to save. |
CacheException | if somethig gos wrong. |
---|
Overridable. Removes object from the persistent storage
hint | the hint object. |
---|
CacheException | if somethig gos wrong. |
---|