https://github.com/zc2638/redis-pool
Resource pool based on redis
https://github.com/zc2638/redis-pool
Last synced: 5 months ago
JSON representation
Resource pool based on redis
- Host: GitHub
- URL: https://github.com/zc2638/redis-pool
- Owner: zc2638
- License: mit
- Created: 2018-08-12T02:39:05.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-06T09:51:45.000Z (almost 8 years ago)
- Last Synced: 2025-10-17T13:01:56.696Z (8 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redis-pool
Resource pool based on redis
# Simple use
```javascript
const Pool = require('@zctod/redis-pool');
const redisConfig = {
port: 6379,
host: '127.0.0.1',
password: '',
db: 0
};
const pool = new Pool();
```
# API
Set initialization name,it can be ignored.
```javascript
pool.setPoolHeadName('order_pool');
```
Set redis config, you can constructor to put.
```javascript
pool.setRedis(redisConfig);
```
Set necessary field and filter code.
```javascript
pool.setCode({
field: ['id'],
filter: ['createCode', 'modelCode']
});
```
Set pool data(must set all field)
```javascript
pool.setPool({
id: 1,
createCode: 5,
modelCode: 20,
}, data, poolName);
```
Get pool data(not to use field)
```javascript
const data = pool.getPool({
createCode: 5,
modelCode: 20,
page: 1,
pageSize: 10,
sort: 'DESC',
}, poolName);
console.log(data);
```
Get pool data one(must use all field)
```javascript
const data = pool.getPoolOne({
id: 5,
}, poolName);
console.log(data);
```
Update pool data one(must use all field)
```javascript
pool.updatePoolOne({
id: 5,
}, data, poolName);
```
Delete pool data one(must use all field)
```javascript
pool.delPoolOne({
id: 5,
}, poolName);
```
Clear pool
```javascript
pool.clearPool(poolName);
```