caching

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheSaveFailed = fmt.Errorf("cache failed to save")

Functions

func NewCacheWrapper added in v1.1.0

func NewCacheWrapper(cache RequestCache) service.Wrapper

NewCacheWrapper

Enable caching throughout the app. Cache will only be applied where the requests implement at least CacheableRequest interface. This is a convenience function to create a wrapper.

func WithCache

func WithCache(cache RequestCache) config.GkBootOption

WithCache

Use to enable caching throughout the app. Cache will only be applied where the requests implement at least CacheableRequest interface

Types

type CacheableRequest

type CacheableRequest interface {
	CacheKey() string
}

CacheableRequest

Any object implementing CacheKey can represent a cache key for the purposes of a gkBoot cache

type RequestCache

type RequestCache interface {
	Get(ctx context.Context, key string) (interface{}, error)
	Put(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error)
}

RequestCache

Any object implementing Get and Put of this interface will qualify for being a RequestCache

type TimedCache

type TimedCache interface {
	CacheDuration() time.Duration
}

TimedCache

Any object implementing CacheDuration will be a timed cache

Jump to

Keyboard shortcuts

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