Class ThreadCacheAccessor

java.lang.Object
org.silverpeas.kernel.cache.service.ThreadCacheAccessor
All Implemented Interfaces:
CacheAccessor<SimpleCache>

public class ThreadCacheAccessor extends Object implements CacheAccessor<SimpleCache>
An accessor to the cache of the current thread. This means the data are per-thread cached and their lifetime doesn't span over the life of the thread.

BE VERY VERY CAREFUL: with thread pool management, the thread is usually never killed because thread creation is time consuming. In pool management the threads are reused to perform another treatment. So, the cache is never by default cleared. This is why you have to clear explicitly the cache with SimpleCache.clear() once you're done with it.

Author:
mmoquillon
  • Method Details

    • getInstance

      public static ThreadCacheAccessor getInstance()
      Gets the single instance of ThreadCacheAccessor.
      Returns:
      the single instance of this class.
    • getCache

      public SimpleCache getCache()
      Description copied from interface: CacheAccessor
      Gets an instance of the cache referred by this accessor. Despite the method can return at each call either the same instance or different instances, the cache represented by the instances will be the same.
      Specified by:
      getCache in interface CacheAccessor<SimpleCache>
      Returns:
      the cache referred by this accessor.