cache

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheMap = sync.Map{}
View Source
var HitCounts = sync.Map{}

Functions

func CleanExpiredCache

func CleanExpiredCache()

定时清理过期缓存

func ClearCache

func ClearCache() error

清空缓存

func DeleteCache

func DeleteCache(key string) error

删除缓存

func GetCurrentGroup

func GetCurrentGroup() int

func LoadCacheFromDB

func LoadCacheFromDB()

从数据库加载缓存

func SetCache

func SetCache(key string, data interface{}, expir time.Time)

设置缓存

func SetCurrentGroup

func SetCurrentGroup(group int)

func UpdateHitCounts

func UpdateHitCounts()

更新命中次数

Types

type CacheItem

type CacheItem struct {
	Key      string `gorm:"primaryKey"`
	Group    int
	Data     []byte
	Expir    time.Time
	HitCount int
}

定义缓存项的结构体

func GetCache

func GetCache(key string) *CacheItem

获取缓存

func GetCacheByGroup

func GetCacheByGroup(group int) []*CacheItem

获取指定组的缓存项

type UserInfo

type UserInfo struct {
	Id      int64
	Account string
	RoleIds string
	Permits []string
}

Jump to

Keyboard shortcuts

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