/** * Puts value into cache * * @param key * @param value * @return value previously stored in cache for this key, or {@code null} if none */ public T put(Class<?> key, T value) { ConcurrentHashMap<String, T> container = getClassLoaderCache(key.getClassLoader(), true); return container.put(key(key), value); }
/** * Puts value into cache * * @param key * the class that will be used as the value's key * @param value * the value that should be stored in cache * @return value previously stored in cache for this key, or {@code null} if none */ public T put(final Class<?> key, final T value) { ConcurrentHashMap<String, T> container = getClassLoaderCache(key.getClassLoader(), true); return container.put(key(key), value); }
/** * Gets value from cache or returns {@code null} if not in cache * * @param key * @return value stored in cache or {@code null} if none */ public T get(Class<?> key) { ConcurrentHashMap<String, T> container = getClassLoaderCache(key.getClassLoader(), false); if (container == null) { return null; } else { return container.get(key(key)); } }
/** * Gets value from cache or returns {@code null} if not in cache * * @param key * the class that is the key for the value * @return value stored in cache or {@code null} if none */ public T get(final Class<?> key) { ConcurrentHashMap<String, T> container = getClassLoaderCache(key.getClassLoader(), false); if (container == null) { return null; } else { return container.get(key(key)); } }