HttpCache

HttpCache

HttpCache

Constructor

new HttpCache(options)

Implements the cache for a data application.
Parameters:
Name Type Description
options Object | *
Source:

Extends

  • EventEmitter2

Methods

add(key, value, ttlopt, callback)

Sets a key value pair in cache.
Parameters:
Name Type Attributes Description
key string A string that represents the key of the cached value
value * The value to be cached
ttl number <optional>
A TTL in seconds. This parameter is optional.
callback function Returns true on success. This parameter is optional.
Source:

ensure(key, fn, callback)

Gets data from cache or executes the defined function and adds the result to the cache with the specified key
Parameters:
Name Type Description
key string | * A string thath represents the of the cached data
fn function A function to execute if data will not be found in cache
callback function A callback function that will return the result or an error, if any.
Source:

get(key, callback)

Gets a cached value defined by the given key.
Parameters:
Name Type Description
key string | *
callback function A callback that returns the cached value, if any.
Source:

init(callback)

Initializes data caching.
Parameters:
Name Type Description
callback function
Source:

remove(key, callback)

Removes a cached value.
Parameters:
Name Type Description
key string A string that represents the key of the cached value
callback function Returns the number of deleted entries. This parameter is optional.
Source:

removeAll(callback)

Flush all cached data.
Parameters:
Name Type Description
callback function This parameter is optional.
Source:

HttpCache

new HttpCache()

Source:
See:

Methods

add(key, value, ttlopt, callback)

Sets a key value pair in cache.
Parameters:
Name Type Attributes Description
key string A string that represents the key of the cached value
value * The value to be cached
ttl number <optional>
A TTL in seconds. This parameter is optional.
callback function Returns true on success. This parameter is optional.
Source:

ensure(key, fn, callback)

Gets data from cache or executes the defined function and adds the result to the cache with the specified key
Parameters:
Name Type Description
key string | * A string thath represents the of the cached data
fn function A function to execute if data will not be found in cache
callback function A callback function that will return the result or an error, if any.
Source:

get(key, callback)

Gets a cached value defined by the given key.
Parameters:
Name Type Description
key string | *
callback function A callback that returns the cached value, if any.
Source:

init(callback)

Initializes data caching.
Parameters:
Name Type Description
callback function
Source:

remove(key, callback)

Removes a cached value.
Parameters:
Name Type Description
key string A string that represents the key of the cached value
callback function Returns the number of deleted entries. This parameter is optional.
Source:

removeAll(callback)

Flush all cached data.
Parameters:
Name Type Description
callback function This parameter is optional.
Source: