mirror of
https://gitee.com/johng/gf
synced 2026-07-08 14:39:50 +08:00
fix issue of dead lock in gcache.doSetWithLockCheck
This commit is contained in:
@ -1,8 +1,28 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
|
||||
"github.com/gogf/gf/g/os/gcache"
|
||||
)
|
||||
|
||||
func localCache() {
|
||||
result := gcache.GetOrSetFunc("test.key.1", func() interface{} {
|
||||
return nil
|
||||
}, 1000*60*2)
|
||||
if result == nil {
|
||||
glog.Error("未获取到值")
|
||||
} else {
|
||||
glog.Infofln("result is $v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCache() {
|
||||
for i := 0; i < 100; i++ {
|
||||
localCache()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := "123"
|
||||
fmt.Println([]byte(s))
|
||||
TestCache()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user