mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated Redis GetKeysForPrefix for ActionPlans
This commit is contained in:
committed by
Dan Christian Bogos
parent
2629be9af0
commit
b781619b98
@@ -343,7 +343,12 @@ func (rs *RedisStorage) getKeysForFilterIndexesKeys(fkeys []string) (keys []stri
|
||||
}
|
||||
|
||||
func (rs *RedisStorage) GetKeysForPrefix(prefix string) ([]string, error) {
|
||||
r := rs.Cmd("KEYS", prefix+"*")
|
||||
var r *redis.Resp
|
||||
if prefix == utils.ACTION_PLAN_PREFIX { //so we can avoid the full scan on scheduler reloads
|
||||
r = rs.Cmd("SMEMBERS", "indx"+utils.ACTION_PLAN_PREFIX)
|
||||
} else {
|
||||
r = rs.Cmd("KEYS", prefix+"*")
|
||||
}
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
}
|
||||
@@ -886,6 +891,7 @@ func (rs *RedisStorage) GetActionPlan(key string, skipCache bool,
|
||||
func (rs *RedisStorage) RemoveActionPlan(key string,
|
||||
transactionID string) error {
|
||||
cCommit := cacheCommit(transactionID)
|
||||
rs.Cmd("SREM", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
err := rs.Cmd("DEL", utils.ACTION_PLAN_PREFIX+key).Err
|
||||
Cache.Remove(utils.CacheActionPlans, key,
|
||||
cCommit, transactionID)
|
||||
@@ -897,6 +903,7 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan,
|
||||
cCommit := cacheCommit(transactionID)
|
||||
if len(ats.ActionTimings) == 0 {
|
||||
// delete the key
|
||||
rs.Cmd("SREM", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
err = rs.Cmd("DEL", utils.ACTION_PLAN_PREFIX+key).Err
|
||||
Cache.Remove(utils.CacheActionPlans, key,
|
||||
cCommit, transactionID)
|
||||
@@ -921,6 +928,7 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan,
|
||||
w := zlib.NewWriter(&b)
|
||||
w.Write(result)
|
||||
w.Close()
|
||||
rs.Cmd("SADD", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
return rs.Cmd("SET", utils.ACTION_PLAN_PREFIX+key, b.Bytes()).Err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user