mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
SecureMapStorage as cache for EventCost
This commit is contained in:
@@ -35,7 +35,7 @@ func NewBareEventCost() *EventCost {
|
||||
Rates: make(ChargedRates),
|
||||
Timings: make(ChargedTimings),
|
||||
Charges: make([]*ChargingInterval, 0),
|
||||
cache: utils.MapStorage{},
|
||||
cache: utils.NewSecureMapStorage(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,12 +160,12 @@ type EventCost struct {
|
||||
Rates ChargedRates
|
||||
Timings ChargedTimings
|
||||
|
||||
cache utils.MapStorage
|
||||
cache *utils.SecureMapStorage
|
||||
}
|
||||
|
||||
func (ec *EventCost) initCache() {
|
||||
if ec != nil {
|
||||
ec.cache = utils.MapStorage{}
|
||||
ec.cache = utils.NewSecureMapStorage()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -952,7 +952,7 @@ func (ec *EventCost) Trim(atUsage time.Duration) (srplusEC *EventCost, err error
|
||||
// FieldAsInterface func to implement DataProvider
|
||||
func (ec *EventCost) FieldAsInterface(fldPath []string) (val interface{}, err error) {
|
||||
if ec.cache == nil {
|
||||
ec.cache = utils.MapStorage{} // fix gob deserialization
|
||||
ec.initCache() // fix gob deserialization
|
||||
}
|
||||
if val, err = ec.cache.FieldAsInterface(fldPath); err != nil {
|
||||
if err != utils.ErrNotFound { // item found in cache
|
||||
|
||||
Reference in New Issue
Block a user