Skip to content

Commit 6cc79c8

Browse files
committed
test: test gob serialization for redis
1 parent d926814 commit 6cc79c8

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

examples/decorator-redis_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,28 @@ func TestRedisCacheFuncWithTTLTimeout(t *testing.T) {
123123
t.Errorf("executeCount should be 5, but get %d", executeCount)
124124
}
125125
}
126+
127+
func TestRedisCacheIntFloat(t *testing.T) {
128+
// Original function
129+
getNum := func(i any) (any) {
130+
return i
131+
}
132+
133+
// Cacheable Function
134+
getNumWithCache := gofnext.CacheFn1(
135+
getNum,
136+
&gofnext.Config{
137+
CacheMap: gofnext.NewCacheRedis("redis-cache-key").ClearAll(),
138+
},
139+
)
140+
141+
// Execute the function multi times in parallel.
142+
i := getNumWithCache(98)
143+
if i.(int) != 98 {
144+
t.Errorf("i should be 98, but get %d", i)
145+
}
146+
j := getNumWithCache(98.5)
147+
if j.(float64) != 98.5 {
148+
t.Errorf("j should be 98.5, but get %f", j)
149+
}
150+
}

gofnext_pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 0f8928923e78fb62f532747dba8ed62e335a3740
1+
Subproject commit 61cc6615697264a042a7b1fa74302715553ac3f2

0 commit comments

Comments
 (0)