ExpirationCache Class
Cache which drops items based on a user-defined expiration criterion, e.g., age. By default, expired items are only removed when they are requested. If you want to "stop the world" and clean out the cache, call clean().
Constructor
ExpirationCache
-
config
Parameters:
-
configObject-
[store]Object optionalData store which implements get,put,remove,clear,keys. If not specified, a new instance of
Y.InstanceManageris created. -
[meta]Function optionalAttaches meta data to an item when it is added to the cache. It receives the value as an argument. If not specified, the default is to timestamp the item.
-
expireFunctionReturns true if the item has expired. It receives the meta data and the value as arguments. If a number is specified, it is assumed to be a duration in milliseconds.
-
[stats]Boolean optionalPass true if you want to collect basic statistics. Pass a function if you want to control what information is stored for each key. The function receives the key, the value, and the stat object.
-
Methods
clean
()
Remove all expired values.
clear
()
Remove all values.
dumpStats
()
Object
This resets all the values.
Returns:
get
-
key
Retrieve a value.
Parameters:
-
keyStringthe key of the object to retrieve
Returns:
put
-
key -
value
Store a value.
Parameters:
-
keyStringthe key of the value
-
valueObjectthe value to store
Returns:
remove
-
key
Remove an value.
Parameters:
-
keyStringthe key of the value
Returns:
replace
-
key -
value
Store a value.
Parameters:
-
keyStringthe key of the value
-
valueObjectthe value to store
