Class EhCacheUtilBase

  • All Implemented Interfaces:
    EhCacheHelper
    Direct Known Subclasses:
    EhCacheUtil

    public class EhCacheUtilBase
    extends Object
    implements EhCacheHelper
    A helper class designed to simplify the work with EhCache library. See the doc for more details.

    Typical usage:

       public MyBean {
         private Cache myCache;
         public MyBean(@NotNull EhCacheUtil cacheUtil) {
           myCache = cacheUtil.createCache("my-cache-name");
         }
         ...
       }
     

    Note: if your cache is not eternal (in ehcache configuration), it will be cleaned up if requested from admin interface or API. Default cache not eternal.

    Author:
    Maxim Podkolzine (maxim.podkolzine@jetbrains.com)
    • Method Detail

      • shutdownCaches

        public void shutdownCaches()
      • getCacheManager

        @Nullable
        protected net.sf.ehcache.CacheManager getCacheManager​(@NotNull
                                                              String configText,
                                                              @NotNull
                                                              Map<String,​String> cacheParams)
      • createCache

        @NotNull
        public net.sf.ehcache.Cache createCache​(@NotNull
                                                String configText,
                                                @NotNull
                                                String name,
                                                @NotNull
                                                Map<String,​String> params)
      • disposeCache

        public void disposeCache​(@NotNull
                                 String name)
        Description copied from interface: EhCacheHelper
        Disposes (flushes on disk and frees resources) a cache with given name
        Specified by:
        disposeCache in interface EhCacheHelper
      • destroyCache

        public boolean destroyCache​(@NotNull
                                    String name)
        Description copied from interface: EhCacheHelper
        Destroys cache with specified name - disposes cache and removes all its data including files stored on disk if cache is persistent.
        Specified by:
        destroyCache in interface EhCacheHelper
        Parameters:
        name - cache name
        Returns:
        true if cache destroyed, and false some error occurred and cache could not be destroyed