@absolunet/ioc2.1.0

View on GitHub

FileDriver

Cache driver that uses the file system to store data.

Extends

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['app', 'driver.config', 'file', 'helper.date'].

fileName :string

Source:
Cache file name, that read given "file" configuration value, or a default value. It should normally be located inside the application storage folder.

config :object.<string, *>

Source:
Inherited From:
Current driver configuration data.

engine :*

Source:
Inherited From:
Current engine accessor.

Methods

(async) ensureFileExists()

Source:
Ensure that the JSON file exists.
Returns:
The async process promise.
Type
Promise

(async) getEntry(key)

Source:
Get cache entry by key.
Parameters:
Name Type Description
key string The cache key.
Returns:
The cache entry.
Type
Promise.<{value: *, expiration: number}>

(async) getContent()

Source:
Get cache entries.
Returns:
All the cache entries.
Type
Promise.<object.<string, {value: *, expiration: number}>>

(async) setContent(content)

Source:
Set cache entries.
Parameters:
Name Type Description
content object.<string, {value: *, expiration: number}> The cache entries.
Returns:
The async process promise.
Type
Promise

get(key, defaultValueopt)

Source:
Overrides:
Retrieve an item from the cache by key.
Parameters:
Name Type Attributes Description
key string The cache key.
defaultValue * <optional>
The default value.
Returns:
The cached value.
Type
Promise.<*>

(async) put(key, value, secondsopt)

Source:
Overrides:
Insert an item in the cache with key and expiration delay.
Parameters:
Name Type Attributes Description
key string The cache key.
value * The value to cache.
seconds number <optional>
The cache expiration delay, in seconds.
Returns:
The async process promise.
Type
Promise

(async) forever(key, value)

Source:
Overrides:
Insert an item in the cache with key forever, without expiration.
Parameters:
Name Type Description
key string The cache key.
value * The value to cache.
Returns:
The async process promise.
Type
Promise

(async) increment(key, incrementopt)

Source:
Overrides:
Increment an item in cache.
Parameters:
Name Type Attributes Default Description
key string The cache key.
increment number <optional>
1 The increment value to add to the cached entry.
Returns:
The async process promise.
Type
Promise

(async) decrement(key, decrementopt)

Source:
Overrides:
Decrement an item in cache.
Parameters:
Name Type Attributes Default Description
key string The cache key.
decrement number <optional>
1 The decrement value to substract from the cached entry.
Returns:
The async process promise.
Type
Promise

(async) delete(key)

Source:
Overrides:
Delete an item in the cache by key.
Parameters:
Name Type Description
key string The cache key.
Returns:
The async process promise.
Type
Promise

(async) flush()

Source:
Overrides:
Delete all items the cache.
Returns:
The async process promise.
Type
Promise

now()

Source:
Inherited From:
Get current time in seconds.
Returns:
The current unix timestamp.
Type
number

setEngine(engine)

Source:
Inherited From:
Set current engine.
Parameters:
Name Type Description
engine * The engine instance.
Returns:
The current instance.
Type
support.mixins.HasEngine