8treenet / Gcache
Licence: apache-2.0
gcache是gorm的中间件,插入后gorm即刻拥有缓存。
Stars: ✭ 271
Programming Languages
go
31211 projects - #10 most used programming language
Projects that are alternatives of or similar to Gcache
express-view-cache
Unobtrusive solution to express framework - cache rendered page, without database requests and rendering.
Stars: ✭ 20 (-92.62%)
Mutual labels: cache
Php Simplecache
A simple script for caching 3rd party API calls in PHP
Stars: ✭ 264 (-2.58%)
Mutual labels: cache
golang api
This is a source code of my golang restful api series on youtube.
Stars: ✭ 36 (-86.72%)
Mutual labels: gorm
codeigniter-cache-helper
📤 A CodeIgniter output cache helper.
Stars: ✭ 19 (-92.99%)
Mutual labels: cache
fiber-boilerplate
This is the go boilerplate on the top of fiber web framework. With simple setup you can use many features out of the box
Stars: ✭ 184 (-32.1%)
Mutual labels: gorm
moka
A high performance concurrent caching library for Rust
Stars: ✭ 346 (+27.68%)
Mutual labels: cache
lambda-cache
Python utility for caching in Lambda Functions
Stars: ✭ 28 (-89.67%)
Mutual labels: cache
Web Archives
Browser extension for viewing archived and cached versions of web pages
Stars: ✭ 263 (-2.95%)
Mutual labels: cache
personJudge
personJudge System 网站预览---->http://47.106.235.227 (账号111,密码12345) 后端:SpringBoot/JPA/mysql/cache/前后端分离(nginx做静态转发)/swagger 前端:bootstrap+Jquery及其插件:jquery-cookie,toastr,steps,validate,wnumb,nouislider,DataTables,layer,chosen,echarts
Stars: ✭ 35 (-87.08%)
Mutual labels: cache
httpcache
An HTTP server that proxies all requests to other HTTP servers and this servers caches all incoming responses objects
Stars: ✭ 23 (-91.51%)
Mutual labels: cache
gcache
gcache是gorm的中间件,插入后gorm即刻拥有缓存。
Overview
- 即插即用
- 旁路缓存
- 数据源使用 Redis
- 防击穿
- 防穿透
安装
$ 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"
- 不支持 Group
- 不支持 Having
- 查询条件和查询参数分离
Example
#查看 example_test.go 了解更多。
more src/github.com/8treenet/gcache/example/example_test.go
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].