mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
better dump consistency
This commit is contained in:
@@ -30,10 +30,11 @@ func newCacheDumper(path string) (*cacheDumper, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (cd *cacheDumper) getDumbDb(prefix string) (*leveldb.DB, error) {
|
||||
func (cd *cacheDumper) getDumpDb(prefix string) (*leveldb.DB, error) {
|
||||
if cd == nil || cd.path == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
db, found := cd.dbMap[prefix]
|
||||
if !found {
|
||||
var err error
|
||||
@@ -47,10 +48,11 @@ func (cd *cacheDumper) getDumbDb(prefix string) (*leveldb.DB, error) {
|
||||
}
|
||||
|
||||
func (cd *cacheDumper) put(prefix, key string, value interface{}) error {
|
||||
db, err := cd.getDumbDb(prefix)
|
||||
db, err := cd.getDumpDb(prefix)
|
||||
if err != nil || db == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
encData, err := cd.dataEncoder.Marshal(value)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -66,7 +68,7 @@ func (cd *cacheDumper) put(prefix, key string, value interface{}) error {
|
||||
}
|
||||
|
||||
func (cd *cacheDumper) load(prefix string) (map[string]interface{}, error) {
|
||||
db, err := cd.getDumbDb(prefix)
|
||||
db, err := cd.getDumpDb(prefix)
|
||||
if err != nil || db == nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -104,7 +106,7 @@ func (cd *cacheDumper) load(prefix string) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
func (cd *cacheDumper) delete(prefix, key string) error {
|
||||
db, err := cd.getDumbDb(prefix)
|
||||
db, err := cd.getDumpDb(prefix)
|
||||
if err != nil || db == nil {
|
||||
return err
|
||||
}
|
||||
@@ -112,7 +114,7 @@ func (cd *cacheDumper) delete(prefix, key string) error {
|
||||
}
|
||||
|
||||
func (cd *cacheDumper) deleteAll(prefix string) error {
|
||||
db, err := cd.getDumbDb(prefix)
|
||||
db, err := cd.getDumpDb(prefix)
|
||||
if err != nil || db == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -87,12 +87,12 @@ func (cs cacheDoubleStore) Delete(key string) {
|
||||
if err := dumper.delete(prefix, key); err != nil {
|
||||
utils.Logger.Info("<cache dumper> delete error: " + err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (cs cacheDoubleStore) DeletePrefix(prefix string) {
|
||||
delete(cs, prefix)
|
||||
|
||||
if err := dumper.deleteAll(prefix); err != nil {
|
||||
utils.Logger.Info("<cache dumper> delete all error: " + err.Error())
|
||||
}
|
||||
|
||||
@@ -751,12 +751,7 @@ func (ms *MongoStorage) cacheAccounting(alsKeys []string) (err error) {
|
||||
return err
|
||||
}
|
||||
utils.Logger.Info("Finished load history caching.")
|
||||
CacheCommitTransaction()
|
||||
utils.Logger.Info(fmt.Sprintf("Cache accounting creation time: %v", time.Since(start)))
|
||||
keys := make(map[string][]string)
|
||||
if len(alsKeys) > 0 {
|
||||
keys[utils.ALIASES_PREFIX] = alsKeys
|
||||
}
|
||||
|
||||
var loadHist *utils.LoadInstance
|
||||
if len(loadHistList) == 0 {
|
||||
|
||||
@@ -423,10 +423,7 @@ func (rs *RedisStorage) cacheAccounting(alsKeys []string) (err error) {
|
||||
utils.Logger.Info("Finished load history caching.")
|
||||
CacheCommitTransaction()
|
||||
utils.Logger.Info(fmt.Sprintf("Cache accounting creation time: %v", time.Since(start)))
|
||||
keys := make(map[string][]string)
|
||||
if len(alsKeys) > 0 {
|
||||
keys[utils.ALIASES_PREFIX] = alsKeys
|
||||
}
|
||||
|
||||
loadHistList, err := rs.GetLoadHistory(1, true)
|
||||
if err != nil || len(loadHistList) == 0 {
|
||||
utils.Logger.Info(fmt.Sprintf("could not get load history: %v (%v)", loadHistList, err))
|
||||
|
||||
Reference in New Issue
Block a user