Class MemoryCache
java.lang.Object
org.pipservices3.components.cache.MemoryCache
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable,org.pipservices3.commons.config.IReconfigurable,ICache
public class MemoryCache
extends Object
implements ICache, org.pipservices3.commons.config.IReconfigurable
Cache that stores values in the process memory.
Remember: This implementation is not suitable for synchronization of distributed processes.
### Configuration parameters ###
- options:
- timeout: default caching timeout in milliseconds (default: 1 minute)
- max_size: maximum number of values stored in this cache (default: 1000)
### Example ###
MemoryCache cache = new MemoryCache();
cache.store("123", "key1", "ABC", 0);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(org.pipservices3.commons.config.ConfigParams config) Configures component by passing configuration parameters.voidRemoves a value from the cache by its key.Retrieves cached value from the cache using its key.Stores value in the cache with expiration time.
-
Constructor Details
-
MemoryCache
public MemoryCache()Creates instance of local in-memory cache component
-
-
Method Details
-
configure
public void configure(org.pipservices3.commons.config.ConfigParams config) throws org.pipservices3.commons.errors.ConfigException Configures component by passing configuration parameters.- Specified by:
configurein interfaceorg.pipservices3.commons.config.IConfigurable- Parameters:
config- configuration parameters to be set.- Throws:
org.pipservices3.commons.errors.ConfigException- when component is in illegal state or configuration validation fails.
-
retrieve
Retrieves cached value from the cache using its key. If value is missing in the cache or expired it returns null. -
store
Stores value in the cache with expiration time. -
remove
Removes a value from the cache by its key.
-