Object -
cache
:
Cache
Represents a Ballerina Cache
which can hold multiple entries and remove entries based on time and size.
Constructor
__init
(int expiryTimeInMillis, int capacity, float evictionFactor)
- expiryTimeInMillis int 900000
-
Time since its last access in which the cache will be expired.
- capacity int 100
-
Maximum number of entries allowed.
- evictionFactor float 0.25
-
The factor which the entries will be evicted once the cache full.
Methods
Checks whether the given key has an associated cache value.
Returns the size of the cache.
Adds the given key, value pair to the provided cache.
Returns the cached value associated with the given key. If the provided cache key is not found, () will be returned.
Removes a cached value from a cache.
Returns all keys from current cache.
Checks whether the given key has an associated cache value.
Parameters
- key string
-
The key to be checked.
-
Return Type
(boolean) true
if the given key has an associated value,false
otherwise.
Adds the given key, value pair to the provided cache.
Parameters
- key string
-
Value which should be used as the key.
- value any
-
Value to be cached.
Returns the cached value associated with the given key. If the provided cache key is not found, () will be returned.
Parameters
- key string
-
Key which is used to retrieve the cached value.
-
Return Type
(any?) The cached value associated with the given key.
Removes a cached value from a cache.
Parameters
- key string
-
Key of the cache entry which needs to be removed.