diff --git a/engine/storage_redis.go b/engine/storage_redis.go index e9b5bb699..12eaba14a 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -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 }