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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址