
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
github.com/8treenet/gcache
$ go get github.com/8treenet/gcache
import (
"github.com/8treenet/gcache"
"github.com/jinzhu/gorm"
"github.com/8treenet/gcache/option""
)
func init() {
//创建 gorm.DB
db, _ = gorm.Open("mysql", "")
opt := option.DefaultOption{}
opt.Expires = 300 //缓存时间, 默认120秒。范围30-43200
opt.Level = option.LevelSearch //缓存级别,默认LevelSearch。LevelDisable:关闭缓存,LevelModel:模型缓存, LevelSearch:查询缓存
opt.AsyncWrite = false //异步缓存更新, 默认false。 insert update delete 成功后是否异步更新缓存。 ps: affected如果未0,不触发更新。
opt.PenetrationSafe = false //开启防穿透, 默认false。 ps:防击穿强制全局开启。
//缓存中间件附加到gorm.DB
gcache.AttachDB(db, &opt, &option.RedisOption{Addr:"localhost:6379"})
}
gorm:"primary_key"
#查看 example_test.go 了解更多。
more src/github.com/8treenet/gcache/example/example_test.go
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.