gocache

package
v0.2.0-alpha.11 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 3 Imported by: 0 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.

Documentation

Index

Constants

View Source
const (
	// GoCacheType represents the storage type as a string value.
	GoCacheType = "go-cache"
	// GoCacheTagPattern represents the tag pattern to be used as a key in specified storage.
	GoCacheTagPattern = "gocache_tag_%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GoCacheClientInterface

type GoCacheClientInterface interface {
	Get(k string) (any, bool)
	GetWithExpiration(k string) (any, time.Time, bool)
	Set(k string, x any, d time.Duration)
	Delete(k string)
	Flush()
}

GoCacheClientInterface represents a github.com/patrickmn/go-cache client.

type GoCacheStore

type GoCacheStore struct {
	// contains filtered or unexported fields
}

GoCacheStore is a store for GoCache (memory) library.

func NewGoCache

func NewGoCache(client GoCacheClientInterface) *GoCacheStore

NewGoCache creates a new store to GoCache (memory) library instance.

func (*GoCacheStore) Clear

func (s *GoCacheStore) Clear(_ context.Context) error

Clear resets all data in the store.

func (*GoCacheStore) Del

func (s *GoCacheStore) Del(_ context.Context, key any) error

Delete removes data in GoCache memoey cache for given key identifier.

func (*GoCacheStore) Get

func (s *GoCacheStore) Get(_ context.Context, key any) (any, error)

Get returns data stored from a given key.

func (*GoCacheStore) GetWithTTL

func (s *GoCacheStore) GetWithTTL(_ context.Context, key any) (any, time.Duration, error)

GetWithTTL returns data stored from a given key and its corresponding TTL.

func (*GoCacheStore) Set

func (s *GoCacheStore) Set(ctx context.Context, key any, value any) error

Set defines data in GoCache memoey cache for given key identifier.

func (*GoCacheStore) SetWithTTL

func (s *GoCacheStore) SetWithTTL(ctx context.Context, key any, value any, ttl time.Duration) error

func (*GoCacheStore) Wait

func (s *GoCacheStore) Wait(_ context.Context)

Jump to

Keyboard shortcuts

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