All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.bordertech.taskmaster.cache.CachingHelper Maven / Gradle / Ivy

The newest version!
package com.github.bordertech.taskmaster.cache;

import com.github.bordertech.didums.Didums;
import com.github.bordertech.taskmaster.cache.impl.CachingHelperProviderDefault;
import javax.cache.Cache;
import javax.cache.configuration.Configuration;
import javax.cache.expiry.Duration;

/**
 * Caching helper based on JSR 107.
 * 

* Allows projects to provide a different mechanism for creating their cache requirements. *

* * @author jonathan */ public final class CachingHelper { private static final CachingHelperProvider PROVIDER = Didums.getService(CachingHelperProvider.class, CachingHelperProviderDefault.class); /** * Private constructor. */ private CachingHelper() { } /** * @return the CachingHelper Provider */ public static CachingHelperProvider getProvider() { return PROVIDER; } /** * Close and release the cache resources. */ public static void closeCacheManager() { PROVIDER.closeCacheManager(); } /** * Create a cache with the default configuration. * * @param name the cache name * @param keyClass the key class type * @param valueClass the value class type * @param the cache entry key type * @param the cache entry value value * @return the cache instance */ public static Cache getOrCreateCache(final String name, final Class keyClass, final Class valueClass) { return PROVIDER.getOrCreateCache(name, keyClass, valueClass); } /** * Create a cache with the specified duration. * * @param name the cache name * @param keyClass the key class type * @param valueClass the value class type * @param duration the cache entry duration * @param the cache entry key type * @param the cache entry value value * @return the cache instance */ public static Cache getOrCreateCache(final String name, final Class keyClass, final Class valueClass, final Duration duration) { return PROVIDER.getOrCreateCache(name, keyClass, valueClass, duration); } /** * Create a cache with the specified configuration. * * @param the cache entry key type * @param the cache entry value value * @param name the cache name * @param keyClass the key class type * @param valueClass the value class type * @param config the cache configuration * @return the cache instance */ public static Cache getOrCreateCache(final String name, final Class keyClass, final Class valueClass, final Configuration config) { return PROVIDER.getOrCreateCache(name, keyClass, valueClass, config); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy