ClearCache from ComputeIndexes with contexts subsystems

This commit is contained in:
porosnicuadrian
2021-09-13 12:55:50 +03:00
committed by Dan Christian Bogos
parent 2e0be2cd9a
commit c7c181856e
2 changed files with 14 additions and 5 deletions

View File

@@ -189,6 +189,10 @@ func (chS *CacheS) Clear(chIDs []string) {
chS.tCache.Clear(chIDs)
}
func (chS *CacheS) RemoveGroup(cacheID, groupID string) {
chS.tCache.RemoveGroup(cacheID, groupID, true, utils.NonTransactional)
}
// BeginTransaction is an exported method from TransCache
func (chS *CacheS) BeginTransaction() string {
return chS.tCache.BeginTransaction()

View File

@@ -398,8 +398,16 @@ func ComputeIndexes(dm *DataManager, tnt, ctx, idxItmType string, IDs *[]string,
transactionID string, getFilters func(tnt, id, ctx string) (*[]string, error), newFltr *Filter) (indexes utils.StringSet, err error) {
indexes = make(utils.StringSet)
var profilesIDs []string
tntCtx := tnt
if ctx != utils.EmptyString {
tntCtx = utils.ConcatenatedKey(tnt, ctx)
}
if IDs == nil { // get all items
Cache.Clear([]string{idxItmType})
if ctx != utils.EmptyString {
Cache.RemoveGroup(idxItmType, tntCtx)
} else {
Cache.Clear([]string{idxItmType})
}
var ids []string
if ids, err = dm.DataDB().GetKeysForPrefix(utils.CacheIndexesToPrefix[idxItmType]); err != nil {
return
@@ -410,10 +418,7 @@ func ComputeIndexes(dm *DataManager, tnt, ctx, idxItmType string, IDs *[]string,
} else {
profilesIDs = *IDs
}
tntCtx := tnt
if ctx != utils.EmptyString {
tntCtx = utils.ConcatenatedKey(tnt, ctx)
}
// early lock to be sure that until we do not write back the indexes
// another goroutine can't create new indexes
refID := guardian.Guardian.GuardIDs(utils.EmptyString,