MCPcopy Create free account
hub / github.com/devfeel/dotweb / TestRuntimeCache_Get

Function TestRuntimeCache_Get

cache/runtime/cache_runtime_test.go:28–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestRuntimeCache_Get(t *testing.T) {
29 cache := NewRuntimeCache()
30 cache.Set(TESTCacheKey, TESTCacheValue, 2)
31 var wg sync.WaitGroup
32
33 // check value
34 wg.Add(1)
35 go func(cache *RuntimeCache, t *testing.T) {
36 time.Sleep(1 * time.Second)
37 value, err := cache.Get(TESTCacheKey)
38
39 test.Nil(t, err)
40 test.Equal(t, TESTCacheValue, value)
41 wg.Done()
42 }(cache, t)
43
44 // check expired
45 wg.Add(1)
46 go func(cache *RuntimeCache, t *testing.T) {
47 time.Sleep(2 * time.Second)
48 value, err := cache.Exists(TESTCacheKey)
49
50 test.Nil(t, err)
51 test.Equal(t, false, value)
52 wg.Done()
53 }(cache, t)
54
55 wg.Wait()
56}
57
58func TestRuntimeCache_GetInt(t *testing.T) {
59 testRuntimeCache(t, TESTCacheIntValue, func(cache *RuntimeCache, key string) (interface{}, error) {

Callers

nothing calls this directly

Calls 6

SetMethod · 0.95
GetMethod · 0.95
ExistsMethod · 0.95
NilFunction · 0.92
EqualFunction · 0.92
NewRuntimeCacheFunction · 0.70

Tested by

no test coverage detected