cache

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cache provides caching adapters for go-micro

The cache package should only be configured via yaml parameters or env variables. Cache instance should be accessed via micro client.Client and used to manually store and retreive cached values.

Package cache provides caching adapters for go-micro

The cache package should only be configured via yaml parameters or env variables. Cache instance should be accessed via micro client.Client and used to manually store and retreive cached values.

Package cache provides caching adapters for go-micro

The cache package should only be configured via yaml parameters or env variables. Cache instance should be accessed via micro client.Client and used to manually store and retreive cached values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(config *config.CacheConfig) cache.Cache

A CustomCache constructor. Called automatically by fx and bootstrapper.

Returns a go-micro cache compliant implementation based on cache configuration. By default returns an in-memory implementation

Types

type CustomCache

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

A CustomCache provides go-micro compatible interface for custom cache providers. This structure is expected to be initialized automatically by fx.

func (*CustomCache) Delete

func (c *CustomCache) Delete(ctx context.Context, key string) error

Delete removes from a gocache provided store by key. It returns the first error encountered while removing a cache entry by key.

A successful Delete returns err == nil.

func (*CustomCache) Get

func (c *CustomCache) Get(ctx context.Context, key string) (interface{}, time.Time, error)

Get retreives from a gocache provided store by key. It returns the value, extraction time and the first error encountered while extracting the value by key.

A successful Get returns value != nil, time.Now() and err == nil.

func (*CustomCache) Put

func (c *CustomCache) Put(ctx context.Context, key string, val interface{}, d time.Duration) error

Put stores into a gocache provided store by key, value and expiration date It returns the first error encountered while settings a new cache value.

A successful Put returns err == nil.

func (*CustomCache) String

func (c *CustomCache) String() string

String returns a gocache provided store name.

Jump to

Keyboard shortcuts

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