mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Added automatic cache reload for filter indexes
This commit is contained in:
committed by
Dan Christian Bogos
parent
a271835a68
commit
cd14ab0a2b
@@ -271,6 +271,19 @@ func (chS *CacheS) V1RemoveItem(args *utils.ArgsGetCacheItemWithOpts,
|
||||
return
|
||||
}
|
||||
|
||||
func (chS *CacheS) V1RemoveItems(args utils.AttrReloadCacheWithOpts,
|
||||
reply *string) (err error) {
|
||||
for key, ids := range args.ArgsCache {
|
||||
if cacheID, has := utils.ArgCacheToInstance[key]; has {
|
||||
for _, id := range ids {
|
||||
chS.tCache.Remove(cacheID, id, true, utils.NonTransactional)
|
||||
}
|
||||
}
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
func (chS *CacheS) V1Clear(args *utils.AttrCacheIDsWithOpts,
|
||||
reply *string) (err error) {
|
||||
chS.tCache.Clear(args.CacheIDs)
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
filterIndexTypes = utils.NewStringSet([]string{utils.MetaPrefix, utils.MetaString, utils.MetaSuffix})
|
||||
FilterIndexTypes = utils.NewStringSet([]string{utils.MetaPrefix, utils.MetaString, utils.MetaSuffix})
|
||||
)
|
||||
|
||||
// newFilterIndex will get the index from DataManager if is not found it will create it
|
||||
@@ -67,7 +67,7 @@ func newFilterIndex(dm *DataManager, idxItmType, tnt, ctx, itemID string, filter
|
||||
return
|
||||
}
|
||||
for _, flt := range fltr.Rules {
|
||||
if !filterIndexTypes.Has(flt.Type) {
|
||||
if !FilterIndexTypes.Has(flt.Type) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
|
||||
newRules := utils.StringSet{} // we only need to determine if we added new rules to rebuild
|
||||
removeRules := utils.StringSet{} // but we need to know what indexes to remove
|
||||
for _, flt := range newFlt.Rules {
|
||||
if !filterIndexTypes.Has(flt.Type) {
|
||||
if !FilterIndexTypes.Has(flt.Type) {
|
||||
continue
|
||||
}
|
||||
isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
|
||||
@@ -498,7 +498,7 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
|
||||
}
|
||||
}
|
||||
for _, flt := range oldFlt.Rules {
|
||||
if !filterIndexTypes.Has(flt.Type) {
|
||||
if !FilterIndexTypes.Has(flt.Type) {
|
||||
continue
|
||||
}
|
||||
isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
|
||||
|
||||
@@ -2479,7 +2479,7 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]i
|
||||
return
|
||||
}
|
||||
case utils.MetaRemove:
|
||||
if err = connMgr.Call(tpr.cacheConns, nil, utils.CacheSv1RemoveItem, cacheArgs, &reply); err != nil {
|
||||
if err = connMgr.Call(tpr.cacheConns, nil, utils.CacheSv1RemoveItems, cacheArgs, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
case utils.MetaClear:
|
||||
@@ -2515,6 +2515,9 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]i
|
||||
cacheIDs = append(cacheIDs, utils.CacheRateProfilesFilterIndexes)
|
||||
cacheIDs = append(cacheIDs, utils.CacheRateFilterIndexes)
|
||||
}
|
||||
if len(flrIDs) != 0 {
|
||||
cacheIDs = append(cacheIDs, utils.CacheReverseFilterIndexes)
|
||||
}
|
||||
if verbose {
|
||||
log.Print("Clearing indexes")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user