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

Function TestRuntimeCache_Decr

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

Source from the content-addressed store, hash-verified

159}
160
161func TestRuntimeCache_Decr(t *testing.T) {
162 cache := NewRuntimeCache()
163 var wg sync.WaitGroup
164 wg.Add(2)
165
166 go func(cache *RuntimeCache) {
167 for i := 0; i < 50; i++ {
168 cache.Decr(TESTCacheKey)
169 }
170
171 wg.Add(-1)
172 }(cache)
173
174 go func(cache *RuntimeCache) {
175 for i := 0; i < 50; i++ {
176 cache.Decr(TESTCacheKey)
177 }
178 wg.Add(-1)
179 }(cache)
180
181 wg.Wait()
182
183 value, e := cache.GetInt(TESTCacheKey)
184 test.Nil(t, e)
185
186 test.Equal(t, -100, value)
187}
188
189func BenchmarkTestRuntimeCache_Get(b *testing.B) {
190 cache := NewRuntimeCache()

Callers

nothing calls this directly

Calls 5

DecrMethod · 0.95
GetIntMethod · 0.95
NilFunction · 0.92
EqualFunction · 0.92
NewRuntimeCacheFunction · 0.70

Tested by

no test coverage detected