Class CacheEntry
java.lang.Object
org.pipservices3.components.cache.CacheEntry
public class CacheEntry extends Object
Data object to store cached values with their keys used by
MemoryCache
-
Constructor Summary
Constructors Constructor Description CacheEntry(String key, Object value, long timeout)
Creates a new instance of the cache entry and assigns its values. -
Method Summary
Modifier and Type Method Description long
getExpiration()
Gets the expiration timeout.String
getKey()
Gets the key to locate the cached value.Object
getValue()
Gets the cached value.boolean
isExpired()
Checks if this value already expired.void
setValue(Object value, long timeout)
Sets a new value and extends its expiration.
-
Constructor Details
-
CacheEntry
Creates a new instance of the cache entry and assigns its values.- Parameters:
key
- a unique key to locate the value.value
- a value to be stored.timeout
- expiration timeout in milliseconds.
-
-
Method Details
-
getKey
Gets the key to locate the cached value.- Returns:
- the value key.
-
getValue
Gets the cached value.- Returns:
- the value object.
-
setValue
Sets a new value and extends its expiration.- Parameters:
value
- a new cached value.timeout
- a expiration timeout in milliseconds.
-
getExpiration
public long getExpiration()Gets the expiration timeout.- Returns:
- the expiration timeout in milliseconds.
-
isExpired
public boolean isExpired()Checks if this value already expired.- Returns:
- true if the value already expires and false otherwise.
-