Class FileCacheBase

  • All Implemented Interfaces:
    Cache, java.util.Observer
    Direct Known Subclasses:

    public abstract class FileCacheBase
    extends CustomizationsAwareCache

    The FileCacheBase is 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.

    It's load method will call the 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 call load(com.microstrategy.utils.cache.CacheHint) again.
    MicroStrategy Web 9.0.0
    • Constructor Detail

      • FileCacheBase

        protected FileCacheBase​(java.lang.String cacheName)
        Base constructor, it will register the Cache in the CacheRegistry and set is refresh time to CacheBase.DEFAULT_FILE_REFRESH_TIME
        cacheName - The name (id) of the Cache.
    • Method Detail

      • 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 he load(com.microstrategy.utils.cache.CacheHint) method.
        reLoad in class CacheBase
        hint - the hint object.
        the object or null.
        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:
        getKey in class CacheBase
        hint - the hint object.
        the key
        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.