MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestCache_IncreaseInt64

Function TestCache_IncreaseInt64

internal/ttlcache/cache_test.go:97–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestCache_IncreaseInt64(t *testing.T) {
98 var a = assert.NewAssertion(t)
99
100 var cache = NewCache[int64]()
101 var unixTime = time.Now().Unix()
102
103 {
104 cache.IncreaseInt64("a", 1, unixTime+3600, false)
105 var item = cache.Read("a")
106 t.Log(item)
107 a.IsTrue(item.Value == 1)
108 a.IsTrue(item.expiredAt == unixTime+3600)
109 }
110 {
111 cache.IncreaseInt64("a", 1, unixTime+3600+1, true)
112 var item = cache.Read("a")
113 t.Log(item)
114 a.IsTrue(item.Value == 2)
115 a.IsTrue(item.expiredAt == unixTime+3600+1)
116 }
117 {
118 cache.Write("b", 1, time.Now().Unix()+3600+2)
119 t.Log(cache.Read("b"))
120 }
121 {
122 cache.IncreaseInt64("b", 1, time.Now().Unix()+3600+3, false)
123 t.Log(cache.Read("b"))
124 }
125}
126
127func TestCache_Read(t *testing.T) {
128 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 5

UnixMethod · 0.80
LogMethod · 0.80
ReadMethod · 0.65
WriteMethod · 0.65
IncreaseInt64Method · 0.45

Tested by

no test coverage detected