Interface Cache

All Known Implementing Classes:
MockCache

public interface Cache
This class manages object caching. An object is cached mainly for read performance and database offloading. The cache can also be used to store transient data which is shared among all nodes of the system.
Author:
Alex Bogdanovski [[email protected]]
  • Method Details

    • contains

      boolean contains(String id)
      Do we have this object in the cache?
      Parameters:
      id - the object's id
      Returns:
      true if in cache
    • contains

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

      <T> void put(String id, T object)
      Store an object in the 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
    • put

      <T> void put(String appid, String id, T object)
      Store an object in the 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

      <T> void put(String appid, String id, T object, Long ttlSeconds)
      Store an object in the 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

      <T> void putAll(Map<String,T> objects)
      Store all objects in cache, except those which are null.
      Type Parameters:
      T - any object, not null
      Parameters:
      objects - map of id - object
    • putAll

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

      <T> T get(String id)
      Read an object from 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
    • get

      <T> T get(String appid, String id)
      Read an object from 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

      <T> Map<String,T> getAll(List<String> ids)
      Read a number of objects given a list of their ids.
      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)
    • getAll

      <T> Map<String,T> getAll(String appid, List<String> ids)
      Read a number of objects given a list of their ids.
      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

      void remove(String id)
      Remove an object from cache.
      Parameters:
      id - the object's id, not null or empty
    • remove

      void remove(String appid, String id)
      Remove an object from cache.
      Parameters:
      appid - the name of the application
      id - the object's id, not null or empty
      See Also:
    • removeAll

      void removeAll()
      Clears the cache.
    • removeAll

      void removeAll(String appid)
      Clears the cache.
      Parameters:
      appid - the name of the application
      See Also:
    • removeAll

      void removeAll(List<String> ids)
      Remove a number of objects from cache given a list of their ids.
      Parameters:
      ids - the ids, not null or empty
    • removeAll

      void removeAll(String appid, List<String> ids)
      Remove a number of objects from cache given a list of their ids.
      Parameters:
      appid - the name of the application
      ids - the ids, not null or empty
      See Also: