Class CaffeineCachingProvider

java.lang.Object
com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider
All Implemented Interfaces:
Closeable, AutoCloseable, javax.cache.spi.CachingProvider

public final class CaffeineCachingProvider extends Object implements javax.cache.spi.CachingProvider
A provider that produces a JCache implementation backed by Caffeine. Typically this provider is instantiated using Caching.getCachingProvider(), which discovers this implementation through a ServiceLoader.

This provider is expected to be used for application life cycle events, like initialization. It is not expected that all requests flow through the provider to obtain the cache manager and cache instances for request operations. Internally, this implementation is synchronized to avoid using excess memory due to its infrequent usage.

  • Field Details

    • DEFAULT_CLASS_LOADER

      private static final ClassLoader DEFAULT_CLASS_LOADER
    • cacheManagers

      private final Map<ClassLoader,Map<URI,javax.cache.CacheManager>> cacheManagers
    • isOsgiComponent

      private boolean isOsgiComponent
  • Constructor Details

    • CaffeineCachingProvider

      public CaffeineCachingProvider()
  • Method Details

    • getDefaultClassLoader

      public ClassLoader getDefaultClassLoader()
      Specified by:
      getDefaultClassLoader in interface javax.cache.spi.CachingProvider
    • getDefaultURI

      public URI getDefaultURI()
      Specified by:
      getDefaultURI in interface javax.cache.spi.CachingProvider
    • getDefaultProperties

      public Properties getDefaultProperties()
      Specified by:
      getDefaultProperties in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public javax.cache.CacheManager getCacheManager()
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public javax.cache.CacheManager getCacheManager(URI uri, ClassLoader classLoader)
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public javax.cache.CacheManager getCacheManager(URI uri, ClassLoader classLoader, Properties properties)
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface javax.cache.spi.CachingProvider
      Specified by:
      close in interface Closeable
    • close

      public void close(ClassLoader classLoader)
      Specified by:
      close in interface javax.cache.spi.CachingProvider
    • close

      public void close(URI uri, ClassLoader classLoader)
      Specified by:
      close in interface javax.cache.spi.CachingProvider
    • isSupported

      public boolean isSupported(javax.cache.configuration.OptionalFeature optionalFeature)
      Specified by:
      isSupported in interface javax.cache.spi.CachingProvider
    • getManagerUri

      private URI getManagerUri(URI uri)
    • getManagerClassLoader

      private ClassLoader getManagerClassLoader(ClassLoader classLoader)
    • activate

      private void activate()
    • isOsgiComponent

      public boolean isOsgiComponent()