Class NullCache

java.lang.Object
org.pipservices3.components.cache.NullCache
All Implemented Interfaces:
ICache

public class NullCache
extends Object
implements ICache
Dummy cache implementation that doesn't do anything.

It can be used in testing or in situations when cache is required but shall be disabled.

See Also:
ICache
  • Constructor Details

    • NullCache

      public NullCache()
      Creates instance of null cache component.
  • Method Details

    • retrieve

      public Object retrieve​(String correlationId, String key)
      Retrieves cached value from the cache using its key. If value is missing in the cache or expired it returns null.
      Specified by:
      retrieve in interface ICache
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a unique value key.
      Returns:
      a cached value or null if value wasn't found or timeout expired.
    • store

      public Object store​(String correlationId, String key, Object value, long timeToLive)
      Stores value in the cache with expiration time.
      Specified by:
      store in interface ICache
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a unique value key.
      value - a value to store.
      timeToLive - expiration timeout in milliseconds.
      Returns:
      a cached value stored in the cache.
    • remove

      public void remove​(String correlationId, String key)
      Removes a value from the cache by its key.
      Specified by:
      remove in interface ICache
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a unique value key.