Redis
This service is used to interact with the Redis database.
Imports
Environment Variables
Do you create variables an .env
file.
REDIS_HOST
Host of the redis.
REDIS_PORT
Port of the redis.
REDIS_PASSWORD
Password of the redis.
Check the example file.
Method of Use
To use this module, you need to inject it into the desired service.
Injecting the module into our service.
Modifying our main.ts
With dependencies
You will need to inject the following interfaces.
AppHostService
IConfigurationService
IValidatorRegexpService
IStringExService
IDebugService
Properties
app
public
This is instance of application.
_client
private
This is the major component of ioredis. Use it to connect to a standalone Redis server or Sentinels.
_redisConfigurationFalsy
private
This is used to check if the environment variables from Redis are missing.
get redisConfigurationFalsy
public
Returns if environment variables from Redis are missing.
Methods
keys
public
Get all keys that match a pattern.
save
public
It saves a key-value pair in the Redis database.
saveBuffer
public
It saves a key-value pair in the Redis database.
update
public
It update a key-value pair in the Redis database.
updateBuffer
public
It update a key-value pair in the Redis database.
findAll
public
It returns all the values in the Redis database.
findOne
public
It returns a value in the Redis database.
delete
public
It delete a key-value pair in the Redis database.
flushall
public
Delete all the keys of all the existing databases, not just the currently selected one.
shutdown
public
This method is used to shutdown application.
onApplicationShutdown
public
Application shutdown hook.
enableShutdownHooks
public
Enable shutdown hooks.
Last updated