Documentation ¶
Index ¶
- Constants
- func DisableCache(db *gorm.DB) *gorm.DB
- func UseCache(db *gorm.DB) *gorm.DB
- type Cache
- type Gorm2Cache
- func (c *Gorm2Cache) AfterCreate(cache *Gorm2Cache) func(db *gorm.DB)
- func (c *Gorm2Cache) AfterDelete(cache *Gorm2Cache) func(db *gorm.DB)
- func (c *Gorm2Cache) AfterUpdate(cache *Gorm2Cache) func(db *gorm.DB)
- func (c *Gorm2Cache) AttachToDB(db *gorm.DB)
- func (c *Gorm2Cache) BatchGetPrimaryCache(ctx context.Context, tableName string, primaryKeys []string) ([]string, error)
- func (c *Gorm2Cache) BatchInvalidatePrimaryCache(ctx context.Context, tableName string, primaryKeys []string) error
- func (c *Gorm2Cache) BatchPrimaryKeyExists(ctx context.Context, tableName string, primaryKeys []string) (bool, error)
- func (c *Gorm2Cache) BatchSetPrimaryKeyCache(ctx context.Context, tableName string, kvs []util.Kv) error
- func (c *Gorm2Cache) GetSearchCache(ctx context.Context, tableName string, sql string, vars ...interface{}) (string, error)
- func (st Gorm2Cache) HitCount() uint64
- func (st Gorm2Cache) HitRate() float64
- func (st Gorm2Cache) IncrHitCount() uint64
- func (st Gorm2Cache) IncrMissCount() uint64
- func (c *Gorm2Cache) Init() error
- func (c *Gorm2Cache) Initialize(db *gorm.DB) (err error)
- func (c *Gorm2Cache) InvalidateAllPrimaryCache(ctx context.Context, tableName string) error
- func (c *Gorm2Cache) InvalidatePrimaryCache(ctx context.Context, tableName string, primaryKey string) error
- func (c *Gorm2Cache) InvalidateSearchCache(ctx context.Context, tableName string) error
- func (st Gorm2Cache) LookupCount() uint64
- func (st Gorm2Cache) MissCount() uint64
- func (c *Gorm2Cache) Name() string
- func (c *Gorm2Cache) ResetCache() error
- func (st Gorm2Cache) ResetHitCount()
- func (c *Gorm2Cache) SearchKeyExists(ctx context.Context, tableName string, SQL string, vars ...interface{}) (bool, error)
- func (c *Gorm2Cache) SetSearchCache(ctx context.Context, cacheValue string, tableName string, sql string, ...) error
- func (c *Gorm2Cache) ShouldCache(_ *gorm.DB, tableName string) bool
- type Group
- type StatsAccessor
Constants ¶
View Source
const InstanceCacheType = "InstanceCacheType"
Variables ¶
This section is empty.
Functions ¶
func DisableCache ¶
DisableCache Deprecated: 设置本次查询不使用缓存 单次逻辑有BUG,设置无效,当Update是禁用cache时,Update不会清理过期的缓存,会导致脏读。
Types ¶
type Cache ¶
type Cache interface { Name() string Initialize(db *gorm.DB) error AttachToDB(db *gorm.DB) ResetCache() error StatsAccessor }
func NewGorm2Cache ¶
func NewGorm2Cache(cacheConfig *config.CacheConfig) (Cache, error)
type Gorm2Cache ¶
type Gorm2Cache struct { Config *config.CacheConfig Logger util.LoggerInterface InstanceId string // contains filtered or unexported fields }
func (*Gorm2Cache) AfterCreate ¶
func (c *Gorm2Cache) AfterCreate(cache *Gorm2Cache) func(db *gorm.DB)
func (*Gorm2Cache) AfterDelete ¶
func (c *Gorm2Cache) AfterDelete(cache *Gorm2Cache) func(db *gorm.DB)
func (*Gorm2Cache) AfterUpdate ¶
func (c *Gorm2Cache) AfterUpdate(cache *Gorm2Cache) func(db *gorm.DB)
func (*Gorm2Cache) AttachToDB ¶
func (c *Gorm2Cache) AttachToDB(db *gorm.DB)
func (*Gorm2Cache) BatchGetPrimaryCache ¶
func (*Gorm2Cache) BatchInvalidatePrimaryCache ¶
func (*Gorm2Cache) BatchPrimaryKeyExists ¶
func (*Gorm2Cache) BatchSetPrimaryKeyCache ¶
func (*Gorm2Cache) GetSearchCache ¶
func (Gorm2Cache) HitRate ¶
func (st Gorm2Cache) HitRate() float64
HitRate returns rate for cache hitting
func (Gorm2Cache) IncrHitCount ¶
func (st Gorm2Cache) IncrHitCount() uint64
IncrHitCount increase hit count
func (Gorm2Cache) IncrMissCount ¶
func (st Gorm2Cache) IncrMissCount() uint64
IncrMissCount increase miss count
func (*Gorm2Cache) Init ¶
func (c *Gorm2Cache) Init() error
func (*Gorm2Cache) Initialize ¶
func (c *Gorm2Cache) Initialize(db *gorm.DB) (err error)
func (*Gorm2Cache) InvalidateAllPrimaryCache ¶
func (c *Gorm2Cache) InvalidateAllPrimaryCache(ctx context.Context, tableName string) error
func (*Gorm2Cache) InvalidatePrimaryCache ¶
func (*Gorm2Cache) InvalidateSearchCache ¶
func (c *Gorm2Cache) InvalidateSearchCache(ctx context.Context, tableName string) error
func (Gorm2Cache) LookupCount ¶
func (st Gorm2Cache) LookupCount() uint64
LookupCount returns lookup count
func (*Gorm2Cache) Name ¶
func (c *Gorm2Cache) Name() string
func (*Gorm2Cache) ResetCache ¶
func (c *Gorm2Cache) ResetCache() error
func (Gorm2Cache) ResetHitCount ¶
func (st Gorm2Cache) ResetHitCount()
func (*Gorm2Cache) SearchKeyExists ¶
func (*Gorm2Cache) SetSearchCache ¶
func (*Gorm2Cache) ShouldCache ¶
func (c *Gorm2Cache) ShouldCache(_ *gorm.DB, tableName string) bool
Click to show internal directories.
Click to hide internal directories.