java.lang.Object
org.miaixz.bus.pager.cache.CacheFactory
Factory for creating and configuring cache instances for SQL caching. It supports creating caches based on a
specified class name or defaulting to
CaffeineCache or SimpleCache.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> org.miaixz.bus.cache.CacheX <K, V> createCache(String sqlCacheClass, String prefix, Properties properties) Creates a SQL cache instance based on the provided class name and properties.
-
Constructor Details
-
CacheFactory
public CacheFactory()
-
-
Method Details
-
createCache
public static <K,V> org.miaixz.bus.cache.CacheX<K,V> createCache(String sqlCacheClass, String prefix, Properties properties) Creates a SQL cache instance based on the provided class name and properties. IfsqlCacheClassis empty, it attempts to create aCaffeineCache, falling back toSimpleCacheif Caffeine is not available. IfsqlCacheClassis provided, it attempts to instantiate that class, supporting constructors withPropertiesandStringarguments, or a default constructor.- Type Parameters:
K- the type of keys maintained by this cacheV- the type of mapped values- Parameters:
sqlCacheClass- the fully qualified class name of the cache implementation to create. Can be null or empty to use default.prefix- a prefix for properties, used to distinguish cache-specific properties.properties- the properties to configure the cache instance.- Returns:
- a new instance of
CacheX - Throws:
org.miaixz.bus.core.lang.exception.PageException- if properties are empty or if there is an error creating the cache instance.
-