Updated RemoveKeysForPrefix on internal DB

This commit is contained in:
Trial97
2021-06-07 13:32:30 +03:00
committed by Dan Christian Bogos
parent 46fc4c7294
commit fa128e5859

View File

@@ -98,13 +98,14 @@ func (iDB *InternalDB) GetKeysForPrefix(prefix string) (ids []string, err error)
}
func (iDB *InternalDB) RemoveKeysForPrefix(prefix string) (err error) {
var keys []string
if keys, err = iDB.GetKeysForPrefix(prefix); err != nil {
return
keyLen := len(utils.DestinationPrefix)
if len(prefix) < keyLen {
return fmt.Errorf("unsupported prefix in RemoveKeysForPrefix: %s", prefix)
}
for _, key := range keys {
Cache.RemoveWithoutReplicate(utils.CacheReverseDestinations, key,
true, utils.NonTransactional)
cacheID := utils.CachePrefixToInstance[prefix[:keyLen]]
for _, key := range Cache.GetItemIDs(cacheID, prefix[keyLen:]) {
Cache.RemoveWithoutReplicate(cacheID, key,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
}
return
}