cache

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ModeKey modeKey = "gorm_cache_mode"

The ModeKey context value specifies the caching Mode for a particular query. I don't really like storing this in the context, but it's the simplest way for now.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CacheEnabled bool
	EaserEnabled bool
	Ttl          time.Duration
	MaxKeys      uint
}

func NewDefaultConfig

func NewDefaultConfig() Config

type DecoratorParams

type DecoratorParams struct {
	fx.In
	Plugin *caches.Caches
	DB     lazy.Lazy[*gorm.DB]
}

type DecoratorResult

type DecoratorResult struct {
	fx.Out
	DB lazy.Lazy[*gorm.DB]
}

func NewDecorator

func NewDecorator(p DecoratorParams) DecoratorResult

type Mode

type Mode int
const (
	// ModeNoCache the query will not be satisfied from the cache, and any existing cache entry will be removed to avoid stale results in future (default)
	ModeNoCache Mode = iota
	// ModeCached the query will be satisfied from the cache if possible, otherwise the result will be stored in the cache
	ModeCached
	// ModeWarm the query will not be satisfied from the cache, but the result will be stored in the cache for future queries using ModeCached
	ModeWarm
)

type Params

type Params struct {
	fx.In
	Config Config
	Logger *zap.SugaredLogger
}

type PluginParams

type PluginParams struct {
	fx.In
	Config Config
	Cacher caches.Cacher
}

type PluginResult

type PluginResult struct {
	fx.Out
	Plugin *caches.Caches
}

func NewPlugin

func NewPlugin(p PluginParams) PluginResult

type Result

type Result struct {
	fx.Out
	Cacher caches.Cacher
}

func NewInMemoryCacher

func NewInMemoryCacher(p Params) Result

Jump to

Keyboard shortcuts

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