Package play.cache

Class Cache


  • public abstract class Cache
    extends java.lang.Object
    The Cache. Mainly an interface to memcached or EhCache. Note: When specifying expiration == "0s" (zero seconds) the actual expiration-time may vary between different cache implementations
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static CacheImpl cacheImpl
      The underlying cache implementation
    • Constructor Summary

      Constructors 
      Constructor Description
      Cache()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clear()
      Clear all data from cache.
      static void delete​(java.lang.String key)
      Delete an element from the cache.
      static <T> T get​(java.lang.String key)
      Retrieve an object.
      static void init()
      Initialize the cache system.
      static void set​(java.lang.String key, java.lang.Object value, java.lang.String expiration)
      Set an element.
      static void stop()
      Stop the cache system.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cacheImpl

        public static CacheImpl cacheImpl
        The underlying cache implementation
    • Constructor Detail

      • Cache

        public Cache()
    • Method Detail

      • set

        public static void set​(java.lang.String key,
                               java.lang.Object value,
                               java.lang.String expiration)
        Set an element.
        Parameters:
        key - Element key
        value - Element value
        expiration - Ex: 10s, 3mn, 8h
      • get

        @Nullable
        public static <T> T get​(@Nonnull
                                java.lang.String key)
        Retrieve an object.
        Parameters:
        key - The element key
        Returns:
        The element value or null
      • delete

        public static void delete​(java.lang.String key)
        Delete an element from the cache.
        Parameters:
        key - The element key
      • clear

        public static void clear()
        Clear all data from cache.
      • init

        public static void init()
        Initialize the cache system.
      • stop

        public static void stop()
        Stop the cache system.