converting to MP, just config in accessRights left
This commit is contained in:
+18
-4
@@ -35,6 +35,13 @@ export const methods = {
|
||||
return
|
||||
}
|
||||
|
||||
const primaryRediscnx = this.allRediscnx.find(cnx => ((payload.key.startsWith(cnx.redisConfig.ChansFilter)) &&(cnx.redisConfig.role=='primary')) )
|
||||
if(!primaryRediscnx){
|
||||
this.sendErr(action, 'No primary redis for this key prefix !', reqid);
|
||||
if(this.debug) console.log('ACTION_SET: No primary redis for this key ', payload.key)
|
||||
return
|
||||
}
|
||||
|
||||
if(payload.value) {
|
||||
let val = null
|
||||
try { val = JSON.stringify(payload.value)}
|
||||
@@ -42,14 +49,14 @@ export const methods = {
|
||||
this.sendErr(action, 'Cannot stringify value object !', reqid);
|
||||
return
|
||||
}
|
||||
if(val.length > this.config.redis.storeMaxSize){
|
||||
if(val.length > primaryRediscnx.redisConfig.storeMaxSize){
|
||||
this.sendErr(action, 'value too large !', reqid);
|
||||
return
|
||||
}
|
||||
let exp = ((payload.expire>0) && (payload.expire<63072000)) ? payload.expire : 63072000
|
||||
await this.rediscnx.redisSet(payload.key, val, exp, this.config.redis.storePrefix)
|
||||
await primaryRediscnx.redisSet(payload.key, val, exp, primaryRediscnx.redisConfig.storePrefix)
|
||||
} else {
|
||||
await this.rediscnx.redisDel(payload.key, this.config.redis.storePrefix)
|
||||
await primaryRediscnx.redisDel(payload.key, primaryRediscnx.redisConfig.storePrefix)
|
||||
}
|
||||
var reply = {
|
||||
'action': action,
|
||||
@@ -91,7 +98,14 @@ export const methods = {
|
||||
return
|
||||
}
|
||||
|
||||
let rawVal = await this.rediscnx.redisGet(payload.key, this.config.redis.storePrefix)
|
||||
const primaryRediscnx = this.allRediscnx.find(cnx => ((payload.key.startsWith(cnx.redisConfig.ChansFilter)) &&(cnx.redisConfig.role=='primary')) )
|
||||
if(!primaryRediscnx){
|
||||
this.sendErr(action, 'No primary redis for this key prefix !', reqid);
|
||||
if(this.debug) console.log('ACTION_GET: No primary redis for this key ', payload.key)
|
||||
return
|
||||
}
|
||||
|
||||
let rawVal = await primaryRediscnx.redisGet(payload.key, primaryRediscnx.redisConfig.storePrefix)
|
||||
let val = null
|
||||
try { val = JSON.parse(rawVal)}
|
||||
catch(err) { console.error('Action GET: Not a json !? ', rawVal) }
|
||||
|
||||
Reference in New Issue
Block a user