Class DefaultCacheTemplate

  • All Implemented Interfaces:
    CacheTemplate

    public class DefaultCacheTemplate
    extends Object
    implements CacheTemplate
    Class description goes HERE
    Author:
    Alfonso Vásquez
    • Constructor Detail

      • DefaultCacheTemplate

        public DefaultCacheTemplate()
    • Method Detail

      • setCacheService

        public void setCacheService​(CacheService cacheService)
      • getKey

        public Object getKey​(Object... keyElements)
        Description copied from interface: CacheTemplate
        Creates a key from the specified elements
        Specified by:
        getKey in interface CacheTemplate
        Parameters:
        keyElements - the key elements
        Returns:
        the key
      • hasObject

        public boolean hasObject​(Context context,
                                 Object... keyElements)
        Description copied from interface: CacheTemplate
        Returns true if the cache contains an object for the specified key elements
        Specified by:
        hasObject in interface CacheTemplate
        Parameters:
        context - the context (needed by the cache service)
        keyElements - the key elements, used to create the final cache key
        Returns:
        true if the cache contains an object for the specified key elements
      • getObject

        public <T> T getObject​(Context context,
                               CachingOptions cachingOptions,
                               org.craftercms.commons.lang.Callback<T> callback,
                               Object... keyElements)
        Description copied from interface: CacheTemplate
        Executes the template, using the specified callback to load the object to cache, if it's not already in the cache.
        Specified by:
        getObject in interface CacheTemplate
        Parameters:
        context - the context (needed by the cache service)
        cachingOptions - the options used for caching.
        callback - the callback to use in case the object is not in the cache
        keyElements - the key elements, used to create the final cache key
        Returns:
        the cached object
      • doGet

        protected <T> T doGet​(Context context,
                              org.craftercms.commons.lang.Callback<T> callback,
                              Object key)
      • loadAndPutInCache

        protected <T> T loadAndPutInCache​(Context context,
                                          CachingOptions cachingOptions,
                                          org.craftercms.commons.lang.Callback<T> callback,
                                          Object key)
      • doPut

        protected <T> T doPut​(Context context,
                              CachingOptions cachingOptions,
                              org.craftercms.commons.lang.Callback<T> callback,
                              Object key,
                              T obj)
      • getCacheLoader

        protected <T> CacheLoader getCacheLoader​(org.craftercms.commons.lang.Callback<T> callback,
                                                 long refreshFrequency)
      • logGetFailure

        protected void logGetFailure​(Context context,
                                     org.craftercms.commons.lang.Callback<?> callback,
                                     Object key,
                                     Exception e)
      • logPutFailure

        protected void logPutFailure​(Context context,
                                     org.craftercms.commons.lang.Callback<?> callback,
                                     Object key,
                                     Object obj,
                                     Exception e)