Documentation
¶
Index ¶
- Constants
- func CallCached[T any](c Cache, ttl time.Duration, fnname string, fn any, args ...any) (T, error)
- func DecodeKey(key string, keyHash KeyHashType) (string, error)
- func StatStr(stat Stat) string
- type Cache
- type CacheBase
- func (cb *CacheBase) CacheKey(fnname string, fn any, args ...any) (string, error)
- func (cb *CacheBase) EncodeKey(key string) string
- func (cb *CacheBase) GetSingleflightWrapper() SingleflightWrapper
- func (cb *CacheBase) GetStat() Stat
- func (cb *CacheBase) IncHit()
- func (cb *CacheBase) IncMiss()
- func (cb *CacheBase) IncShared()
- func (cb *CacheBase) LaunchRefresh(fn func())
- type CacheConfig
- type InMemoryCache
- type InMemoryCacheConfig
- type KeyHashType
- type SingleflightWrapper
- type Stat
- type ValkeyCache
- type ValkeyCacheConfig
Constants ¶
View Source
const DefaultKeyHash = KEY_HASH_BASE64
Variables ¶
This section is empty.
Functions ¶
func CallCached ¶
Types ¶
type Cache ¶
type Cache interface {
CacheKey(fnname string, fn any, args ...any) (string, error)
Get(key string) (string, bool, error)
Set(key string, value string, ttl time.Duration) error
Invalidate(key string) error
IncHit()
IncMiss()
GetStat() Stat
LaunchRefresh(fn func())
GetSingleflightWrapper() SingleflightWrapper
}
type CacheBase ¶
type CacheBase struct {
// contains filtered or unexported fields
}
func NewCacheBase ¶
func (*CacheBase) GetSingleflightWrapper ¶ added in v1.55.0
func (cb *CacheBase) GetSingleflightWrapper() SingleflightWrapper
func (*CacheBase) LaunchRefresh ¶
func (cb *CacheBase) LaunchRefresh(fn func())
type CacheConfig ¶
type InMemoryCache ¶
type InMemoryCache struct {
*CacheBase
// contains filtered or unexported fields
}
func NewInMemoryCache ¶
func NewInMemoryCache( ctx context.Context, wg *sync.WaitGroup, config InMemoryCacheConfig, ) *InMemoryCache
func (*InMemoryCache) Invalidate ¶
func (imc *InMemoryCache) Invalidate(key string) error
type InMemoryCacheConfig ¶
type InMemoryCacheConfig struct {
CacheConfig
CleanupInterval time.Duration
}
type KeyHashType ¶
type KeyHashType int
const ( KEY_HASH_BASE64 KeyHashType = iota KEY_HASH_SHA256 KEY_HASH_SHA512 KEY_HASH_HEX KEY_HASH_NONE )
func ParseKeyHashType ¶
func ParseKeyHashType(s string) KeyHashType
func (KeyHashType) String ¶
func (k KeyHashType) String() string
type SingleflightWrapper ¶ added in v1.55.0
type ValkeyCache ¶
type ValkeyCache struct {
*CacheBase
// contains filtered or unexported fields
}
func NewValkeyCache ¶
func NewValkeyCache( ctx context.Context, wg *sync.WaitGroup, config ValkeyCacheConfig, ) *ValkeyCache
func (*ValkeyCache) Invalidate ¶
func (vc *ValkeyCache) Invalidate(key string) error
type ValkeyCacheConfig ¶
Click to show internal directories.
Click to hide internal directories.