Class SpringCacheManager

java.lang.Object
com.okta.spring.boot.sdk.cache.SpringCacheManager
All Implemented Interfaces:
com.okta.sdk.cache.CacheManager, org.springframework.beans.factory.InitializingBean

public class SpringCacheManager extends Object implements com.okta.sdk.cache.CacheManager, org.springframework.beans.factory.InitializingBean
A Okta SDK CacheManager implementation that wraps a Spring CacheManager instance. This allows the Okta SDK to use your existing Spring caching mechanism so you only need to configure one caching implementation.

This implementation effectively acts as an adapter or bridge from the Okta SDK cacheManager API to the Spring CacheManager API.

Since:
0.3.0
  • Constructor Details

    • SpringCacheManager

      public SpringCacheManager()
    • SpringCacheManager

      public SpringCacheManager(org.springframework.cache.CacheManager springCacheManager)
      Constructs a new SpringCacheManager instance that wraps (delegates to) the specified Spring CacheManager instance.
      Parameters:
      springCacheManager - the target Spring cache manager to wrap.
  • Method Details

    • setSpringCacheManager

      public void setSpringCacheManager(org.springframework.cache.CacheManager cacheManager)
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • getCache

      public <K, V> com.okta.sdk.cache.Cache<K,V> getCache(String name)
      Consults the wrapped Spring CacheManager instance to obtain a named Spring Cache instance. The instance is wrapped and returned as a SpringCache instance, which acts as a bridge/adapter over Spring's existing Cache API.
      Specified by:
      getCache in interface com.okta.sdk.cache.CacheManager
      Type Parameters:
      K - The cache key type
      V - The cache value type
      Parameters:
      name - the name of the cache to acquire.
      Returns:
      the Cache with the given name