func (self *ApierV1) GetCachedItemAge(itemId string, reply *utils.CachedItemAge) error { if len(itemId) == 0 { return fmt.Errorf("%s:ItemId", utils.ErrMandatoryIeMissing.Error()) } cachedItemAge := new(utils.CachedItemAge) var found bool for idx, cacheKey := range []string{utils.DESTINATION_PREFIX + itemId, utils.RATING_PLAN_PREFIX + itemId, utils.RATING_PROFILE_PREFIX + itemId, utils.ACTION_PREFIX + itemId, utils.SHARED_GROUP_PREFIX + itemId, utils.ALIASES_PREFIX + itemId, utils.LCR_PREFIX + itemId} { if age, err := cache2go.GetKeyAge(cacheKey); err == nil { found = true switch idx { case 0: cachedItemAge.Destination = age case 1: cachedItemAge.RatingPlan = age case 2: cachedItemAge.RatingProfile = age case 3: cachedItemAge.Action = age case 4: cachedItemAge.SharedGroup = age case 5: cachedItemAge.Alias = age case 6: cachedItemAge.LcrProfiles = age } } } if !found { return utils.ErrNotFound } *reply = *cachedItemAge return nil }
func (self *ApierV1) GetCachedItemAge(itemId string, reply *utils.CachedItemAge) error { if len(itemId) == 0 { return fmt.Errorf("%s:ItemId", utils.ERR_MANDATORY_IE_MISSING) } cachedItemAge := new(utils.CachedItemAge) var found bool for idx, cacheKey := range []string{engine.DESTINATION_PREFIX + itemId, engine.RATING_PLAN_PREFIX + itemId, engine.RATING_PROFILE_PREFIX + itemId, engine.ACTION_PREFIX + itemId, engine.SHARED_GROUP_PREFIX + itemId, engine.RP_ALIAS_PREFIX + itemId, engine.ACC_ALIAS_PREFIX + itemId} { if age, err := cache2go.GetKeyAge(cacheKey); err == nil { found = true switch idx { case 0: cachedItemAge.Destination = age case 1: cachedItemAge.RatingPlan = age case 2: cachedItemAge.RatingProfile = age case 3: cachedItemAge.Action = age case 4: cachedItemAge.SharedGroup = age case 5: cachedItemAge.RatingAlias = age case 6: cachedItemAge.AccountAlias = age } } } if !found { return errors.New(utils.ERR_NOT_FOUND) } *reply = *cachedItemAge return nil }