Skip to content

Commit

Permalink
Create cache_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
itmisx authored Jan 17, 2023
1 parent 854171f commit bf151d7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cache

import (
"log"
"testing"
"time"
)

func TestXxx(t *testing.T) {
// string test
for i := 0; i < 1; i++ {
go func() {
Set("key1", 1, time.Second*4, func(key string, value interface{}) {
log.Println("callback1", key, value)
})
Expire("key1", time.Second*7)
}()
}
for i := 0; i < 1; i++ {
go func() {
HSet("hkey1", "hfield1", 1, time.Second*8, func(key string, field string, value interface{}) {
log.Println("callback2", key, field, value)
})
Expire("hkey1", time.Second*7)
}()
}
log.Println(Del("afsdf"))
log.Println(Get("key1"))
log.Println(Get("key2"))
log.Println(HDel("hkey1", "hfield1"))
log.Println(HGet("hkey1", "hfield1"))
log.Println(HGet("hkey1", "hfield2"))
time.Sleep(time.Second * 10)
for {
time.Sleep(time.Second)
}
}

0 comments on commit bf151d7

Please sign in to comment.