Class: Server

Server

new Server(client, configopt)

Create a new instance of the server interface.
Parameters:
Name Type Attributes Description
client RedisClient
config Object <optional>
configuration values. See Server#_configure
Source:

Methods

add(items, callbackopt)

Add several items to the cache. These is an array of object, each with an ID (.id prop) that defines its position in the ordered sequence of all items.
Parameters:
Name Type Attributes Description
items Array.<Object> array of items
Properties
Name Type Description
id Number id of the item
callback function <optional>
callback(err)
Source:

addOne(idopt, item, callbackopt)

Add one item to the cache. Ths ID is represents its position in the ordered sequence of all items.
Parameters:
Name Type Attributes Description
id Number <optional>
id of the item
item Object | String the item itself
callback function <optional>
callback(err)
Source:

getSize(callback)

Return the size of the cache i.e. number of items in the cache. Note that this function queries the redis server to determine this size and it is therefore not stored in process memory. This ensure a consistent value across multiple application instances using a single redis server DB.
Parameters:
Name Type Description
callback function callback(err, size)
Source:

purge(callbackopt)

Purge the cache. This destroys your cache's items and its existence in the backing store. This might be useful if your want to reclaim memory in Redis. This function is DANGEROUS. How? If on app startup, we decide to be purging the cache, it would mean that anytime a new application is started, the cache is purged. Such random purges may cause host instability due to the numerous creation and purges requests (especially if we are starting multiple instances at once). It is therefore recommended that you only purge cache when you intend to do so. For example, from an admin panel, you can purge the cache (maybe the cache for the host is misbehaving or during debugging).
Parameters:
Name Type Attributes Description
callback function <optional>
callback(err)
Source:

removeOne(id, callbackopt)

Remove one item from the cache. This ID represents its position in the ordered sequence of all items.
Parameters:
Name Type Attributes Description
id Number id of the item
callback function <optional>
callback(err)
Source: