CDRS - Cache StoreSMCost for HA setups

This commit is contained in:
DanB
2016-06-17 11:16:34 +02:00
parent 9c10c6d0c1
commit 4c42f21b03

View File

@@ -510,9 +510,18 @@ func (self *CdrServer) V1ProcessCDR(cdr *CDR, reply *string) error {
// RPC method, differs from storeSMCost through it's signature
func (self *CdrServer) V1StoreSMCost(attr AttrCDRSStoreSMCost, reply *string) error {
cacheKey := "V1StoreSMCost" + attr.Cost.CGRID + attr.Cost.RunID + attr.Cost.OriginID
if item, err := self.getCache().Get(cacheKey); err == nil && item != nil {
if item.Value != nil {
*reply = item.Value.(string)
}
return item.Err
}
if err := self.storeSMCost(attr.Cost, attr.CheckDuplicate); err != nil {
self.getCache().Cache(cacheKey, &cache2go.CacheItem{Err: err})
return utils.NewErrServerError(err)
}
self.getCache().Cache(cacheKey, &cache2go.CacheItem{Value: utils.OK})
*reply = utils.OK
return nil
}