cache

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterCreate

func AfterCreate(cache *Gorm2Cache) func(db *gorm.DB)

func AfterDelete

func AfterDelete(cache *Gorm2Cache) func(db *gorm.DB)

func AfterQuery

func AfterQuery(cache *Gorm2Cache) func(db *gorm.DB)

func AfterUpdate

func AfterUpdate(cache *Gorm2Cache) func(db *gorm.DB)

func BeforeQuery

func BeforeQuery(cache *Gorm2Cache) func(db *gorm.DB)

func GenInstanceId

func GenInstanceId() string

GenInstanceId 生成实例ID

func GenSearchCacheKey

func GenSearchCacheKey(tableName string, sql string, vars ...interface{}) string

GenSearchCacheKey 生成搜索缓存key

Types

type Gorm2Cache

type Gorm2Cache struct {
	Config Gorm2CacheConfig
	// contains filtered or unexported fields
}

func (*Gorm2Cache) CleanCache

func (g *Gorm2Cache) CleanCache(key string) error

CleanCache 清理缓存

func (*Gorm2Cache) GetBean

func (g *Gorm2Cache) GetBean(key string, ptr any) error

func (*Gorm2Cache) GetHitCount

func (g *Gorm2Cache) GetHitCount() int64

func (*Gorm2Cache) IncrHitCount

func (g *Gorm2Cache) IncrHitCount()

func (*Gorm2Cache) Initialize

func (g *Gorm2Cache) Initialize(db *gorm.DB) (err error)

func (*Gorm2Cache) IsCache

func (g *Gorm2Cache) IsCache(db *gorm.DB) bool

IsCache 是否需要缓存

func (*Gorm2Cache) Name

func (g *Gorm2Cache) Name() string

func (*Gorm2Cache) ResetHitCount

func (g *Gorm2Cache) ResetHitCount()

func (*Gorm2Cache) SetBean

func (g *Gorm2Cache) SetBean(key string, cacheValue any, expires int64) error

func (*Gorm2Cache) TableName

func (g *Gorm2Cache) TableName(db *gorm.DB) string

TableName 获取表名

type Gorm2CacheConfig

type Gorm2CacheConfig struct {
	Enable bool `yaml:"enable"` // 是否开启缓存
}

Jump to

Keyboard shortcuts

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