mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
GetActionPlan from cache with GetCloned
This commit is contained in:
2
cache/cache.go
vendored
2
cache/cache.go
vendored
@@ -161,6 +161,8 @@ func GetCloned(key string) (cln interface{}, err error) {
|
||||
return nil, utils.NewCGRError(utils.Cache,
|
||||
utils.NotFoundCaps, utils.ItemNotFound,
|
||||
fmt.Sprintf("item with key <%s> was not found in <%s>", key))
|
||||
} else if origVal == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if _, canClone := origVal.(utils.Cloner); !canClone {
|
||||
return nil, utils.NewCGRError(utils.Cache,
|
||||
|
||||
@@ -1374,11 +1374,14 @@ func (ms *MongoStorage) RemoveActionTriggers(key string, transactionID string) e
|
||||
|
||||
func (ms *MongoStorage) GetActionPlan(key string, skipCache bool, transactionID string) (ats *ActionPlan, err error) {
|
||||
if !skipCache {
|
||||
if x, ok := cache.Get(utils.ACTION_PLAN_PREFIX + key); ok {
|
||||
if x != nil {
|
||||
return x.(*ActionPlan), nil
|
||||
if x, err := cache.GetCloned(key); err != nil {
|
||||
if err.Error() != utils.ItemNotFound { // Only consider cache if item was found
|
||||
return nil, err
|
||||
}
|
||||
} else if x == nil { // item was placed nil in cache
|
||||
return nil, utils.ErrNotFound
|
||||
} else {
|
||||
return x.(*ActionPlan), nil
|
||||
}
|
||||
}
|
||||
var kv struct {
|
||||
|
||||
@@ -980,11 +980,14 @@ func (rs *RedisStorage) RemoveActionTriggers(key string, transactionID string) (
|
||||
func (rs *RedisStorage) GetActionPlan(key string, skipCache bool, transactionID string) (ats *ActionPlan, err error) {
|
||||
key = utils.ACTION_PLAN_PREFIX + key
|
||||
if !skipCache {
|
||||
if x, ok := cache.Get(key); ok {
|
||||
if x != nil {
|
||||
return x.(*ActionPlan), nil
|
||||
if x, err := cache.GetCloned(key); err != nil {
|
||||
if err.Error() != utils.ItemNotFound { // Only consider cache if item was found
|
||||
return nil, err
|
||||
}
|
||||
} else if x == nil { // item was placed nil in cache
|
||||
return nil, utils.ErrNotFound
|
||||
} else {
|
||||
return x.(*ActionPlan), nil
|
||||
}
|
||||
}
|
||||
var values []byte
|
||||
|
||||
Reference in New Issue
Block a user