-
Notifications
You must be signed in to change notification settings - Fork 1
Install
npm i -S node-file-caching
This package has 4 main methods that can be used and assumes that the defualt cache folder is .cache
with a default TTL of 60 minutes.
This method has 2 mandatory and 2 optional parameters and you'll need to use it for setting the cache. The output of this method will be true
.
key
= Your own cache identifier
value
= Value that you would like to store
ttl
= This is optional. Is set to 60 minutes by default.
location
= This is optional. Is set to default location of
.cache
, however, please don't use it as currently there's no state of configuration for persisting the cache location.
const {set} = require('node-file-caching');
set("myCacheKey",{foo:"bar"});
This method has 1 mandatory parameter, called key
, which is used to get the cache file. This method has 2 response states:
-
false
= when the key doesn't exist of cache key doesn't have any content -
string
= it will return the file contents of thekey
key
= Cache key identifier
const {get} = require('node-file-caching');
const cacheData = get("myCacheKey");
This method has 1 mandatory parameter, called key
, which is used to identify the cache file and remove it. This method has 2 response states:
-
false
= when the key doesn't exist -
true
= when the key has been removed
key
= Cache key identifier
const {remove} = require('node-file-caching');
remove("myCacheKey");
This method will clear the .cache
folder of any files and it will return true
as response.