Proper init of cache options

This commit is contained in:
DanB
2019-04-19 18:37:37 +02:00
parent 9caee16f43
commit 0f974ce9a0
2 changed files with 10 additions and 6 deletions

View File

@@ -32,11 +32,11 @@ type AttributeWithCache struct {
}
//SetAttributeProfile add/update a new Attribute Profile
func (apierV2 *ApierV2) SetAttributeProfile(extAlsPrfWrp *AttributeWithCache, reply *string) error {
if missing := utils.MissingStructFields(extAlsPrfWrp.ExternalAttributeProfile, []string{"Tenant", "ID"}); len(missing) != 0 {
func (apierV2 *ApierV2) SetAttributeProfile(arg *AttributeWithCache, reply *string) error {
if missing := utils.MissingStructFields(arg.ExternalAttributeProfile, []string{utils.Tenant, utils.ID}); len(missing) != 0 {
return utils.NewErrMandatoryIeMissing(missing...)
}
alsPrf, err := extAlsPrfWrp.ExternalAttributeProfile.AsAttributeProfile()
alsPrf, err := arg.ExternalAttributeProfile.AsAttributeProfile()
if err != nil {
return utils.APIErrorHandler(err)
}
@@ -44,14 +44,17 @@ func (apierV2 *ApierV2) SetAttributeProfile(extAlsPrfWrp *AttributeWithCache, re
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheAttributeProfiles and store it in database
if err := apierV2.DataManager.SetLoadIDs(map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
if err := apierV2.DataManager.SetLoadIDs(
map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
args := engine.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: alsPrf.TenantID(),
}
if err := apierV2.CallCache(v1.GetCacheOpt(extAlsPrfWrp.Cache), args); err != nil {
if err := apierV2.ApierV1.CallCache(
v1.GetCacheOpt(arg.Cache),
args); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -515,8 +515,9 @@ func InitAttrReloadCache() (rpl AttrReloadCache) {
rpl.AttributeProfileIDs = &[]string{}
rpl.ChargerProfileIDs = &[]string{}
rpl.DispatcherProfileIDs = &[]string{}
rpl.DispatcherHostIDs = &[]string{}
rpl.DispatcherRoutesIDs = &[]string{}
return rpl
return
}
type CacheKeys struct {