Module bus.pager

Class CacheFactory

java.lang.Object
org.miaixz.bus.pager.cache.CacheFactory

public abstract class CacheFactory extends Object
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 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. If sqlCacheClass is empty, it attempts to create a CaffeineCache, falling back to SimpleCache if Caffeine is not available. If sqlCacheClass is provided, it attempts to instantiate that class, supporting constructors with Properties and String arguments, or a default constructor.
      Type Parameters:
      K - the type of keys maintained by this cache
      V - 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.