BaseCacheManager

BaseCacheManager

The base cache manager for all cache managers.

Constructor

new BaseCacheManager(client, options)

Description:
  • Creates a cache manager.

Source:
Parameters:
Name Type Description
client Client

The client instance.

options Object

The options for the cache manager.

Properties
Name Type Description
structureType Object

The structure type for the cache manager.

Throws:
TypeError

Members

(readonly) size :Number

Description:
  • Returns the size of the cache.

Source:

Returns the size of the cache.

Type:
  • Number

Methods

_intervalCallback() → {void}

Description:
  • The callback for expiring buckets.

Source:
Returns:
Type
void

clear() → {void}

Description:
  • Clears the cache.

Source:
Returns:
Type
void

delete(key) → {Boolean}

Description:
  • Deletes a key from the cache.

Source:
Parameters:
Name Type Description
key String

The key to delete.

Returns:

Whether the key was deleted or not.

Type
Boolean

expireBucket(bucket) → {void}

Description:
  • Expires a bucket.

Source:
Parameters:
Name Type Description
bucket String

The bucket to expire.

Returns:
Type
void

forEach(callback) → {void}

Description:
  • Calls a function on each item in the cache.

Source:
Parameters:
Name Type Description
callback function

Callback function to run on each item in the cache.

Returns:
Type
void

get(key, options) → (nullable) {Object}

Description:
  • Gets a value from the cache.

Source:
Parameters:
Name Type Description
key String

The key to get.

options Object

The options for the get method.

Properties
Name Type Description
useRules Boolean

Whether to use rules or not.

Throws:
TypeError
Returns:

The value from the cache.

Type
Object

set(key, value, expiry) → {Object}

Description:
  • Sets a value in the cache.

Source:
Parameters:
Name Type Default Description
key String

The key to set.

value Object

The value to set.

expiry Number 0

The expiry time in seconds.

Throws:
TypeError
Returns:

The value that was set.

Type
Object

toJSON(format) → {Object}

Description:
  • Returns the JSON representation of this structure.

Source:
Parameters:
Name Type Description
format Number

The format to return the data in.

Returns:
Type
Object