Constructor
new CacheClient()
Methods
applyOptions()
- Description:
Prepare options to be used safely, parse the reserved params from the url
clear()
- Description:
Clear all or only matched keys from the cache
close()
- Description:
Close current connection, ports.... not valid after this call
del()
- Description:
Delete an item from the cache
get()
- Description:
Returns an item from the cache by a key, callback is required and it acceptes only the item, on any error null or undefined will be returned
incr()
- Description:
Add/substract a number from the an item, returns new number in the callback if provided, in case of an error null/indefined should be returned
limiter()
- Description:
Rate limit check, by default it uses the server LRU cache meaning it works within one physical machine only.
The options must have the following properties:
- name - unique id, can be IP address, account id, etc...
- rate, max, interval - same as for
metrics.TokenBucketrate limiter.
The callback arguments must be:
- 1st arg is a delay to wait till the bucket is ready again,
- 2nd arg is an object with the bucket state: { delay:, count:, total:, elapsed: }
lock()
- Description:
Lock by name by default return an error
put()
- Description:
Store an item in the cache,
options.ttlcan be used to specify TTL in milliseconds
stats()
- Description:
Returns the cache statistics to the callback as the forst argument, the object tructure is specific to each implementstion
unlock()
- Description:
Unlock by name