mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 11:06:25 +05:00
cache refactoring for save and load
This commit is contained in:
25
engine/response_cache_test.go
Normal file
25
engine/response_cache_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRCacheSetGet(t *testing.T) {
|
||||
rc := NewResponseCache(5 * time.Second)
|
||||
rc.Cache("test", &CacheItem{Value: "best"})
|
||||
v, err := rc.Get("test")
|
||||
if err != nil || v.Value.(string) != "best" {
|
||||
t.Error("Error retriving response cache: ", v, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRCacheExpire(t *testing.T) {
|
||||
rc := NewResponseCache(1 * time.Microsecond)
|
||||
rc.Cache("test", &CacheItem{Value: "best"})
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
_, err := rc.Get("test")
|
||||
if err == nil {
|
||||
t.Error("Error expiring response cache: ", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user