Class CacheUtil


  • @Deprecated
    public final class CacheUtil
    extends java.lang.Object
    Deprecated.
    We now recommend you simply use your own new ConcurrentHashMap<>() instead.
    Cache wannabe.

    This class wanted to be Cache when it was grown up. Currently it's actually just a nested ConcurrentMap, and thus has fairly limited real value.

    The usage of static methods here, instead of an (OSGi) "service" (dependency inject-able in tests!) makes it impossible to easily properly use code relying on this in component tests (as there would be no automatic reset between tests; you would have to manually destroyCache(String) @Before each test).

    This class' "static" Singleton doesn't play nice with OSGi e.g. for hot reload.

    This class' (necessary) use <?> generics causes @SuppressWarnings("unchecked") when used.

    Perhaps you would like to use Google Guava's simple Caches, if not a full blown JSR 107 javax.cache (JCache) implementation, such as Infinispan or Ehcache, instead of this class?

    Author:
    unascribed (Ericsson India?) - original code, Michael Vorburger.ch - JavaDoc
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void createCache​(java.lang.String cacheName)
      Deprecated.
       
      static void destroyCache​(java.lang.String cacheName)
      Deprecated.
       
      static java.util.concurrent.ConcurrentMap<?,​?> getCache​(java.lang.String cacheName)
      Deprecated.
       
      static boolean isCacheValid​(java.lang.String cacheName)
      Deprecated.
       
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getCache

        public static java.util.concurrent.ConcurrentMap<?,​?> getCache​(java.lang.String cacheName)
        Deprecated.
      • createCache

        public static void createCache​(java.lang.String cacheName)
        Deprecated.
      • isCacheValid

        public static boolean isCacheValid​(java.lang.String cacheName)
        Deprecated.
      • destroyCache

        public static void destroyCache​(java.lang.String cacheName)
        Deprecated.