GetActionPlan from cache with GetCloned

This commit is contained in:
DanB
2016-11-22 18:13:35 +01:00
parent 6a7610ef21
commit e657fb3ca8
3 changed files with 14 additions and 6 deletions

2
cache/cache.go vendored
View File

@@ -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,

View File

@@ -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 {

View File

@@ -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