new Cache(options)
Constructor
Parameters:
Name | Type | Argument | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
Methods
-
clear()
-
Clears cache entries
-
destroy()
-
Stops gc and clears all data including timeouts
-
gc()
-
Garbage collecting
-
gcIsRunning()
-
Determinates whatever GC is running
Returns:
- Type
- Boolean
-
gcStart()
-
Starts garbage collecting
-
gcStop()
-
Stops garbage collecting
-
get(key)
-
Gets value of key if exists
Parameters:
Name Type Description key
String Returns:
- Type
- *
-
has(key)
-
Parameters:
Name Type Description key
String Returns:
- Type
- Boolean
-
keys()
-
Returns:
- Type
- Array
-
remove(key)
-
Deletes entry
Parameters:
Name Type Description key
String -
set(key, value, ttl)
-
Sets
Parameters:
Name Type Description key
String value
* ttl
Number -
trim()
-
Trims cache to setted limit
-
values()
-
Returns all cached values
Returns:
- Type
- Array