@absolunet/ioc2.1.0

View on GitHub

DatabaseDriver

Cache driver that uses the database to store data.

Extends

Members

(static) dependencies :Array.<string>

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

connection :Knex

Source:
Connection instance based on configuration.

config :object.<string, *>

Source:
Inherited From:
Current driver configuration data.

engine :*

Source:
Inherited From:
Current engine accessor.

Methods

(async) getResult(key)

Source:
Get full database result from key.
Parameters:
Name Type Description
key string The cache key.
Returns:
The cache database entry.
Type
Promise.<({key: string, value: string, expires_at: (string|null)}|undefined)>

(async) getFromResult(result, defaultValueopt)

Source:
Get value from result.
Parameters:
Name Type Attributes Default Description
result Object | undefined The cache database entry.
defaultValue * <optional>
null The default value to use if the result is empty, expired or not parsable.
Returns:
The cached value.
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