memory

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache containse memory cache storage

func New

func New(ctx context.Context, cfg bigcache.Config) (*Cache, error)

New memory cache

func NewTimeout

func NewTimeout(ctx context.Context, timeout time.Duration) (*Cache, error)

NewTimeout returns cache with timout value

func (*Cache) Del

func (c *Cache) Del(ctx context.Context, key string) error

Del removes cache item by key

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string, target any) error

Get cached item

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, value any, _ time.Duration) error

Set cache item NOTE: timeout is not used, it can be defined globaly

func (*Cache) TrySet

func (c *Cache) TrySet(ctx context.Context, key string, value any, lifetime time.Duration) error

TrySet only if not exists

Jump to

Keyboard shortcuts

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