caches

package
v1.2.34 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, param any) (p []byte, has bool, err error)

func Load added in v1.2.12

func Load(ctx context.Context, param any, value any) (has bool, err error)

func New

func New() services.Service

New use @cache, and param must implement KeyParam. unit of ttl is seconds and default value is 10 seconds. @cache get @cache set 10 @cache remove @cache get-set 10

func NewWithStore

func NewWithStore(store Store) services.Service

func Remove

func Remove(ctx context.Context, param interface{}) (err error)

func Set

func Set(ctx context.Context, param interface{}, value interface{}, ttl time.Duration) (err error)

Types

type KeyParam

type KeyParam interface {
	CacheKey(ctx context.Context) (key []byte, err error)
}

type Store

type Store interface {
	services.Component
	Get(ctx context.Context, key []byte) (value []byte, has bool, err error)
	Set(ctx context.Context, key []byte, value []byte, ttl time.Duration) (err error)
	Remove(ctx context.Context, key []byte) (err error)
}

Jump to

Keyboard shortcuts

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