This commit is contained in:
2021-01-25 23:42:47 -05:00
parent 10d10079aa
commit e585683664
22 changed files with 3116 additions and 1268 deletions

View File

@@ -4,7 +4,7 @@ const {createClient} = require('redis');
const {promisify} = require('util');
const config = {
prefix: 'sso_'
prefix: 'deploy_'
}
function client() {
@@ -13,6 +13,9 @@ function client() {
const _client = client();
const SCAN = promisify(_client.SCAN).bind(_client);
module.exports = {
client: client,
HGET: promisify(_client.HGET).bind(_client),
@@ -24,4 +27,18 @@ module.exports = {
HGETALL: promisify(_client.HGETALL).bind(_client),
SMEMBERS: promisify(_client.SMEMBERS).bind(_client),
RENAME: promisify(_client.RENAME).bind(_client),
HSCAN: promisify(_client.HSCAN).bind(_client),
SCAN: async function(match){
let coursor = 0;
let results = [];
do{
let res = await SCAN(coursor, 'MATCH', config.prefix+match);
coursor = Number(res[0]);
results.push(...res[1].map(e => e.replace(config.prefix, '')))
} while(coursor);
return results
}
};