Simplify the use of Redis
Using npm:
$ npm install lia-redis
import {RedisInstaller,RedisConfig} from "lia-redis";
const TARGET = {};
const config = {
host: "127.0.0.1",
port: 6379
}
const installer = new RedisInstaller(config,TARGET,'sys|info');
await installer.load();
await TARGET.REDIS.SET('KEY','Hello')
const result = await TARGET.REDIS.GET('KEY')
console.log(result);
import {RedisInstaller,RedisConfig,RedisConfigs} from "lia-redis";
const TARGET = {};
const config = {
APP1:{
host: "127.0.0.1",
port: 6379
}
}
const installer = new RedisInstaller(config,TARGET,'sys|info');
await installer.load();
The multi-instance mode is basically the same as the single-instance mode, except that the database instance needs to be specified on the REDIS instance, for example:
await TARGET.REDIS.APP1.SET('KEY','Hello')
const result = await TARGET.REDIS.APP1.GET('KEY')
console.log(result);
For other operations, please refer to redis