cache_aside

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

cache-aside

Implement the cache-aside pattern based on Redis, and combine it with Golang generics.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheAside

type CacheAside[T CacheAsideKey] struct {
	// contains filtered or unexported fields
}

func NewCacheAside

func NewCacheAside[T CacheAsideKey](redisClient rueidis.Client, metaLoader MetaLoader[T], expireTime time.Duration) *CacheAside[T]

func (*CacheAside[T]) Query

func (c *CacheAside[T]) Query(ctx context.Context, expireTime time.Duration, cacheKey string, v T) (T, error)

type CacheAsideKey

type CacheAsideKey interface {
	ParseCacheKey(cacheKey string) error
	EncodeCacheKey() string
}

type MetaLoader

type MetaLoader[T CacheAsideKey] interface {
	CacheAsideLoad(context.Context, T) (T, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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