diff --git a/general_tests/acntacts_test.go b/general_tests/acntacts_test.go index 77201578f..0501674d3 100644 --- a/general_tests/acntacts_test.go +++ b/general_tests/acntacts_test.go @@ -21,7 +21,6 @@ import ( "reflect" "testing" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" ) @@ -68,8 +67,10 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,,false,false,10` } csvr.WriteToDatabase(false, false, false) - cache.Flush() - dbAcntActs.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + engine.Cache.Clear(nil) + dbAcntActs.LoadDataDBCache(nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil) expectAcnt := &engine.Account{ID: "cgrates.org:1"} if acnt, err := dbAcntActs.DataDB().GetAccount("cgrates.org:1"); err != nil { diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go index 83f4ccccc..9b56e0f2c 100644 --- a/general_tests/auth_test.go +++ b/general_tests/auth_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -79,19 +78,21 @@ RP_ANY,DR_ANY_1CNT,*any,10` t.Error("No account saved") } - cache.Flush() - dbAuth.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + engine.Cache.Clear(nil) + dbAuth.LoadDataDBCache(nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil) - if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { + if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) } - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 2 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 2 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } - if cachedActions := cache.CountEntries(utils.ACTION_PREFIX); cachedActions != 0 { + if cachedActions := len(engine.Cache.GetItemIDs(utils.CacheActions, "")); cachedActions != 0 { t.Error("Wrong number of cached actions found", cachedActions) } } diff --git a/general_tests/costs1_test.go b/general_tests/costs1_test.go index 8cd32bcb2..b7316650e 100644 --- a/general_tests/costs1_test.go +++ b/general_tests/costs1_test.go @@ -20,7 +20,6 @@ package general_tests import ( "testing" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" ) @@ -73,13 +72,15 @@ RP_SMS1,DR_SMS_1,ALWAYS,10` t.Fatal(err) } csvr.WriteToDatabase(false, false, false) - cache.Flush() - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + engine.Cache.Clear(nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil) - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 3 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 3 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } } diff --git a/general_tests/datachrg1_test.go b/general_tests/datachrg1_test.go index dc6d69344..ab94d5b8c 100644 --- a/general_tests/datachrg1_test.go +++ b/general_tests/datachrg1_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" ) @@ -60,13 +59,15 @@ RP_DATA1,DR_DATA_2,TM2,10` t.Fatal(err) } csvr.WriteToDatabase(false, false, false) - cache.Flush() - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + engine.Cache.Clear(nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 1 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 1 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } } diff --git a/general_tests/ddazmbl1_test.go b/general_tests/ddazmbl1_test.go index a244e8880..5c5d87ea1 100644 --- a/general_tests/ddazmbl1_test.go +++ b/general_tests/ddazmbl1_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/scheduler" "github.com/cgrates/cgrates/utils" @@ -117,20 +116,22 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` } else if acnt == nil { t.Error("No account saved") } - cache.Flush() + engine.Cache.Clear(nil) - dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + dataDB.LoadDataDBCache(nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) - if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { + if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) } - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 2 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 2 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } - if cachedActions := cache.CountEntries(utils.ACTION_PREFIX); cachedActions != 0 { + if cachedActions := len(engine.Cache.GetItemIDs(utils.CacheActions, "")); cachedActions != 0 { t.Error("Wrong number of cached actions found", cachedActions) } } diff --git a/general_tests/ddazmbl2_test.go b/general_tests/ddazmbl2_test.go index 9ec6332f0..369535bea 100644 --- a/general_tests/ddazmbl2_test.go +++ b/general_tests/ddazmbl2_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/scheduler" "github.com/cgrates/cgrates/utils" @@ -115,19 +114,21 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` } else if acnt == nil { t.Error("No account saved") } - cache.Flush() - dataDB2.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + engine.Cache.Clear(nil) + dataDB2.LoadDataDBCache(nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil) - if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { + if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) } - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 2 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 2 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } - if cachedActions := cache.CountEntries(utils.ACTION_PREFIX); cachedActions != 0 { + if cachedActions := len(engine.Cache.GetItemIDs(utils.CacheActions, "")); cachedActions != 0 { t.Error("Wrong number of cached actions found", cachedActions) } } diff --git a/general_tests/ddazmbl3_test.go b/general_tests/ddazmbl3_test.go index 088f2da21..34e0d0fed 100644 --- a/general_tests/ddazmbl3_test.go +++ b/general_tests/ddazmbl3_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/scheduler" "github.com/cgrates/cgrates/utils" @@ -113,19 +112,21 @@ RP_UK,DR_UK_Mobile_BIG5,ALWAYS,10` } else if acnt == nil { t.Error("No account saved") } - cache.Flush() - dataDB3.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + engine.Cache.Clear(nil) + dataDB3.LoadDataDBCache(nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) - if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 { + if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 { t.Error("Wrong number of cached destinations found", cachedDests) } - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 2 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 2 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } - if cachedActions := cache.CountEntries(utils.ACTION_PREFIX); cachedActions != 0 { + if cachedActions := len(engine.Cache.GetItemIDs(utils.CacheActions, "")); cachedActions != 0 { t.Error("Wrong number of cached actions found", cachedActions) } } diff --git a/general_tests/smschrg1_test.go b/general_tests/smschrg1_test.go index 81b356ada..8afa97c83 100644 --- a/general_tests/smschrg1_test.go +++ b/general_tests/smschrg1_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/cache" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -58,13 +57,13 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) { t.Fatal(err) } csvr.WriteToDatabase(false, false, false) - cache.Flush() + engine.Cache.Clear(nil) dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) - if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 1 { + if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 1 { t.Error("Wrong number of cached rating plans found", cachedRPlans) } - if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 { + if cachedRProfiles := len(engine.Cache.GetItemIDs(utils.CacheRatingProfiles, "")); cachedRProfiles != 0 { t.Error("Wrong number of cached rating profiles found", cachedRProfiles) } } diff --git a/utils/response_cache_test.go b/utils/response_cache_test.go index 6da75ef35..9390f8c2f 100644 --- a/utils/response_cache_test.go +++ b/utils/response_cache_test.go @@ -24,7 +24,7 @@ import ( func TestRCacheSetGet(t *testing.T) { rc := NewResponseCache(5 * time.Second) - rc.Cache("test", &CacheItem{Value: "best"}) + rc.Cache("test", &ResponseCacheItem{Value: "best"}) v, err := rc.Get("test") if err != nil || v.Value.(string) != "best" { t.Error("Error retriving response cache: ", v, err)