2.2.0 • Published 2 months ago
@actvalue/mysql-redis-cache v2.2.0
@actvalue/mysql-redis-cache
Wrapper for MySQL queries with Redis caching.
Install
yarn add @actvalue/mysql-redis-cache
npm i @actvalue/mysql-redis-cache
Client Usage
The client is used to execute queries and caching the result.
import { MRCClient } from '@actvalue/mysql-redis-cache';
const mysqlConfig = {
host: '<mysql host>',
port: 3306,
user: '<user>',
password: '<password>',
database: '<db>',
connectionLimit: 5,
};
const redisConfig = {
username: '<user>',
password: '<password>',
socket: {
host: '<redis host>',
port: 6379,
connectionTimeout: 30000,
},
};
// create instance and connect
const mrc = new MRCClient(mysqlConfig, redisConfig);
// execute queries
const query = 'SELECT * FROM table WHERE name = ?';
const params = ['Alberto'];
const paramNames = ['Name'];
const ttl = 3600; // default is 24h
const result = await mrc.queryWithCache(query, params, paramNames, ttl);
Server Usage
The server is used to delete cached queries.
import { MRCServer } from '@actvalue/mysql-redis-cache';
const redisConfig = {
username: '<user>',
password: '<password>',
socket: {
host: '<redis host>',
port: 6379,
connectionTimeout: 30000,
},
};
// create instance and connect
const mrc = new MRCServer(redisConfig);
// delete all queries concerning StoreId = 6
await mrc.dropOutdatedCache(['StoreId'], [6]);
2.2.0
2 months ago
2.0.3
1 year ago
2.0.2
1 year ago
2.0.4
1 year ago
2.1.0
1 year ago
2.0.1
1 year ago
2.0.0
1 year ago
1.2.0
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.0
2 years ago
0.1.0
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago