vagrant update

This commit is contained in:
2023-06-26 22:18:42 -04:00
parent 7659b77d67
commit deca906ce1
7 changed files with 634 additions and 596 deletions
+12 -14
View File
@@ -5,21 +5,19 @@ const config = {
prefix: 'proxy_'
}
function client() {
return createClient(config);
}
var _client = createClient(config);
_client.connect()
const _client = client();
module.exports = {
client: client,
HGET: promisify(_client.HGET).bind(_client),
HDEL: promisify(_client.HDEL).bind(_client),
SADD: promisify(_client.SADD).bind(_client),
SREM: promisify(_client.SREM).bind(_client),
DEL: promisify(_client.DEL).bind(_client),
HSET: promisify(_client.HSET).bind(_client),
HGETALL: promisify(_client.HGETALL).bind(_client),
SMEMBERS: promisify(_client.SMEMBERS).bind(_client),
RENAME: promisify(_client.RENAME).bind(_client),
client: _client,
// HGET: promisify(_client.HGET).bind(_client),
// HDEL: promisify(_client.HDEL).bind(_client),
// SADD: promisify(_client.SADD).bind(_client),
// SREM: promisify(_client.SREM).bind(_client),
// DEL: promisify(_client.DEL).bind(_client),
// HSET: promisify(_client.HSET).bind(_client),
// HGETALL: promisify(_client.HGETALL).bind(_client),
// SMEMBERS: promisify(_client.SMEMBERS).bind(_client),
// RENAME: promisify(_client.RENAME).bind(_client),
};
+7 -3
View File
@@ -1,8 +1,11 @@
'use strict';
const client = require('../utils/redis');
const {createClient} = require('redis');
const objValidate = require('../utils/object_validate');
var client = createClient({});
client.connect()
let table = {};
@@ -20,7 +23,7 @@ table.get = async function(data){
let res = await client.HGETALL(`${this._name}_${data[this._key]}`);
// If the redis query resolved to something, prepare the data.
if(res){
if(Object.keys(res).length){
// Redis always returns strings, use the keyMap schema to turn them
// back to native values.
@@ -106,12 +109,13 @@ table.add = async function(data, noMemberAdd){
// Add the values for this entry.
for(let key of Object.keys(data)){
await client.HSET(`${this._name}_${data[this._key]}`, key, data[key]);
await client.hSet(`${this._name}_${data[this._key]}`, key, String(data[key]));
}
// return the created redis entry as entry instance.
return await this.get(data[this._key]);
} catch(error){
console.error('redis model | table.add:', error)
throw error;
}
};