gcache

package
v1.2.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDisable = iota + 1 // 禁用缓存
	LevelModel              // 模型缓存
	LevelAll                // 全部缓存
)

缓存等级

Variables

View Source
var DefaultOption = &Option{
	Expires:         time.Second * 120,
	Level:           LevelAll,
	AsyncWrite:      true,
	RefreshExpires:  true,
	PenetrationSafe: true,
	Logger:          logger.Logger{},
}
View Source
var IsCount = errors.New("is count")
View Source
var PrimaryCacheHit = errors.New("primary cache hit")
View Source
var SearchCacheHit = errors.New("search cache hit")

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(tx *gorm.DB, rdb *redis.Client, opt *Option) Engine

func (*Engine) AfterQuery

func (e *Engine) AfterQuery(tx *gorm.DB)

func (*Engine) BeforeQuery

func (e *Engine) BeforeQuery(tx *gorm.DB)

func (*Engine) Bind

func (e *Engine) Bind()

Bind bind cache engine to gorm

func (*Engine) CreateCallback

func (e *Engine) CreateCallback(tx *gorm.DB)

func (*Engine) DeleteCallback

func (e *Engine) DeleteCallback(tx *gorm.DB)

func (*Engine) UpdateCallback

func (e *Engine) UpdateCallback(tx *gorm.DB)

type JsonSearch

type JsonSearch struct {
	PrimaryKeys []string `json:"primary_keys"`
}

type Model

type Model interface{}

type Option

type Option struct {
	Expires         time.Duration    // 默认120秒,30-43200
	Level           int              // 默认LevelSearch,LevelDisable:关闭,LevelModel:模型缓存, LevelAll:全部缓存
	AsyncWrite      bool             // 默认false, insert update delete 成功后是否异步更新缓存
	RefreshExpires  bool             // 是否缓存刷新缓存时长
	PenetrationSafe bool             // 默认false, 开启防穿透。
	Logger          logger.Interface //日志记录
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL