Package com.microstrategy.utils.cache
Class FileCacheBase
- java.lang.Object
-
- com.microstrategy.utils.cache.CacheBase
-
- com.microstrategy.utils.cache.CustomizationsAwareCache
-
- com.microstrategy.utils.cache.FileCacheBase
-
- All Implemented Interfaces:
Cache,java.util.Observer
- Direct Known Subclasses:
ResourceCache
public abstract class FileCacheBase extends CustomizationsAwareCache
The
It's load method will call theFileCacheBaseis the base class for cached objects that depend on a single file, that is, the file they depend on cannot be customized through the plug-ins infrastructure, nor can it internally depend on other configuration files.doLoad(com.microstrategy.utils.cache.CacheHint)and save the file's ModificationTime in a table. When reload is call it will compare the current file's ModificationTime against the value in the table and only if different will callload(com.microstrategy.utils.cache.CacheHint)again.- Since:
- MicroStrategy Web 9.0.0
-
-
Field Summary
-
Fields inherited from class com.microstrategy.utils.cache.CacheBase
alias, DEFAULT_FILE_REFRESH_TIME, DEFAULT_REFRESH_TIME, DEFAULT_STATISTIC_TIME, DEFAULT_SYS_TIMEOUT, DEFAULT_USER_TIMEOUT, NO_KEY, NO_REFRESH, NO_STATISTIC, NO_TIMEOUT
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileCacheBase(java.lang.String cacheName)Base constructor, it will register the Cache in theCacheRegistryand set is refresh time toCacheBase.DEFAULT_FILE_REFRESH_TIME
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.ObjectdoLoad(CacheHint hint)This abstract method is called by the load method to perform the actual loading.protected java.lang.ObjectgetKey(CacheHint hint)Returns the key of the cache element based on the hint.protected java.lang.StringgetPath(CacheHint hint)Returns the path for the given hint.protected java.lang.Objectload(CacheHint hint)Loads an element from a file and keeps track of its last modification time.protected java.lang.ObjectreLoad(CacheHint hint, java.lang.Object ob)Checks if the file corresponding to the hint has changed (by comparing its last modification time with the value stored by the load method), and if the same, just returns the same object, otherwise it will call delegate tot heload(com.microstrategy.utils.cache.CacheHint)method.-
Methods inherited from class com.microstrategy.utils.cache.CustomizationsAwareCache
update
-
Methods inherited from class com.microstrategy.utils.cache.CacheBase
canUpdate, clear, close, configure, contains, delete, get, getName, getRefreshTime, getStatisticTime, getTimeout, getWithoutRefresh, logStatistic, onHintClose, onTimer, put, refresh, remove, save, setRefreshTime, setStatisticTime, setTimeout, size, store, unLoad
-
-
-
-
Constructor Detail
-
FileCacheBase
protected FileCacheBase(java.lang.String cacheName)
Base constructor, it will register the Cache in theCacheRegistryand set is refresh time toCacheBase.DEFAULT_FILE_REFRESH_TIME- Parameters:
cacheName- The name (id) of the Cache.
-
-
Method Detail
-
load
protected java.lang.Object load(CacheHint hint) throws CacheException
Loads an element from a file and keeps track of its last modification time. The actual loading of the element is delegated to thedoLoad(com.microstrategy.utils.cache.CacheHint)method.- Specified by:
loadin classCacheBase- Parameters:
hint- the hint object.- Returns:
- the object or null.
- Throws:
CacheException- if somethig gos wrong.
-
reLoad
protected java.lang.Object reLoad(CacheHint hint, java.lang.Object ob) throws CacheException
Checks if the file corresponding to the hint has changed (by comparing its last modification time with the value stored by the load method), and if the same, just returns the same object, otherwise it will call delegate tot heload(com.microstrategy.utils.cache.CacheHint)method.- Overrides:
reLoadin classCacheBase- Parameters:
hint- the hint object.- Returns:
- the object or null.
- Throws:
CacheException- if somethig gos wrong.
-
getKey
protected java.lang.Object getKey(CacheHint hint) throws CacheException
Returns the key of the cache element based on the hint. In this scenario, the hint itself is the key.- Specified by:
getKeyin classCacheBase- Parameters:
hint- the hint object.- Returns:
- the key
- Throws:
CacheException- if somethig gos wrong.
-
getPath
protected java.lang.String getPath(CacheHint hint)
Returns the path for the given hint. This implementation simply uses the hint value.
-
doLoad
protected abstract java.lang.Object doLoad(CacheHint hint) throws CacheException
This abstract method is called by the load method to perform the actual loading. In this method, subclasses needs to load the file and parse it, and return the object they actually want cached.- Throws:
CacheException
-
-