Class MockCache

java.lang.Object
com.erudika.para.core.cache.MockCache
All Implemented Interfaces:
Cache

@Singleton public class MockCache extends Object implements Cache
Author:
Alex Bogdanovski [[email protected]]
  • Constructor Details

    • MockCache

      public MockCache()
  • Method Details

    • contains

      public boolean contains(String appid, String id)
      Description copied from interface: Cache
      Do we have this object in the cache?
      Specified by:
      contains in interface Cache
      Parameters:
      appid - the name of the application
      id - the object's id
      Returns:
      true if in cache
      See Also:
    • put

      public <T> void put(String appid, String id, T object)
      Description copied from interface: Cache
      Store an object in the cache.
      Specified by:
      put in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      appid - the name of the application
      id - the object's id, not null or empty
      object - the object itself, not null
      See Also:
    • put

      public <T> void put(String appid, String id, T object, Long ttlSeconds)
      Description copied from interface: Cache
      Store an object in the cache.
      Specified by:
      put in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      appid - the name of the application
      id - the object's id, not null or empty
      object - the object itself, not null
      ttlSeconds - the time to live for an object before it is evicted from the cache.
      See Also:
    • putAll

      public <T> void putAll(String appid, Map<String,T> objects)
      Description copied from interface: Cache
      Store all objects in cache, except those which are null.
      Specified by:
      putAll in interface Cache
      Type Parameters:
      T - any object, not null
      Parameters:
      appid - the name of the application
      objects - map of id - object
      See Also:
    • get

      public <T> T get(String appid, String id)
      Description copied from interface: Cache
      Read an object from cache.
      Specified by:
      get in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      appid - the name of the application
      id - the object's id, not null or empty
      Returns:
      the object from cache or null if not found
      See Also:
    • getAll

      public <T> Map<String,T> getAll(String appid, List<String> ids)
      Description copied from interface: Cache
      Read a number of objects given a list of their ids.
      Specified by:
      getAll in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      appid - the name of the application
      ids - the ids, not null or empty
      Returns:
      a map of the objects that are contained in cache (may be empty)
      See Also:
    • remove

      public void remove(String appid, String id)
      Description copied from interface: Cache
      Remove an object from cache.
      Specified by:
      remove in interface Cache
      Parameters:
      appid - the name of the application
      id - the object's id, not null or empty
      See Also:
    • removeAll

      public void removeAll(String appid)
      Description copied from interface: Cache
      Clears the cache.
      Specified by:
      removeAll in interface Cache
      Parameters:
      appid - the name of the application
      See Also:
    • removeAll

      public void removeAll(String appid, List<String> ids)
      Description copied from interface: Cache
      Remove a number of objects from cache given a list of their ids.
      Specified by:
      removeAll in interface Cache
      Parameters:
      appid - the name of the application
      ids - the ids, not null or empty
      See Also:
    • contains

      public boolean contains(String id)
      Description copied from interface: Cache
      Do we have this object in the cache?
      Specified by:
      contains in interface Cache
      Parameters:
      id - the object's id
      Returns:
      true if in cache
    • put

      public <T> void put(String id, T object)
      Description copied from interface: Cache
      Store an object in the cache.
      Specified by:
      put in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      id - the object's id, not null or empty
      object - the object itself, not null
    • putAll

      public <T> void putAll(Map<String,T> objects)
      Description copied from interface: Cache
      Store all objects in cache, except those which are null.
      Specified by:
      putAll in interface Cache
      Type Parameters:
      T - any object, not null
      Parameters:
      objects - map of id - object
    • get

      public <T> T get(String id)
      Description copied from interface: Cache
      Read an object from cache.
      Specified by:
      get in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      id - the object's id, not null or empty
      Returns:
      the object from cache or null if not found
    • getAll

      public <T> Map<String,T> getAll(List<String> ids)
      Description copied from interface: Cache
      Read a number of objects given a list of their ids.
      Specified by:
      getAll in interface Cache
      Type Parameters:
      T - the type of object to be cached
      Parameters:
      ids - the ids, not null or empty
      Returns:
      a map of the objects that are contained in cache (may be empty)
    • remove

      public void remove(String id)
      Description copied from interface: Cache
      Remove an object from cache.
      Specified by:
      remove in interface Cache
      Parameters:
      id - the object's id, not null or empty
    • removeAll

      public void removeAll()
      Description copied from interface: Cache
      Clears the cache.
      Specified by:
      removeAll in interface Cache
    • removeAll

      public void removeAll(List<String> ids)
      Description copied from interface: Cache
      Remove a number of objects from cache given a list of their ids.
      Specified by:
      removeAll in interface Cache
      Parameters:
      ids - the ids, not null or empty