memory

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncodingCache

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

EncodingCache cache in map by decode and encode.

func NewEncodingCache

func NewEncodingCache(opts ...Option) *EncodingCache

NewEncodingCache create new cache.

func (*EncodingCache) Delete

func (c *EncodingCache) Delete(ctx context.Context, key interface{}) error

Delete delete item from cache.

func (*EncodingCache) Get

func (c *EncodingCache) Get(ctx context.Context, key, value interface{}) error

Get gets item from cache and delete if expired.

func (*EncodingCache) Set

func (c *EncodingCache) Set(ctx context.Context, key, value interface{}, ttl time.Duration) error

Set sets item to cache.

type MapCache added in v0.0.2

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

MapCache in memoty by map.

func NewMapCache added in v0.0.2

func NewMapCache() *MapCache

NewMapCache creates new map cache.

func (*MapCache) Delete added in v0.0.2

func (c *MapCache) Delete(ctx context.Context, key interface{}) error

Delete delete item from cache.

func (*MapCache) Get added in v0.0.2

func (c *MapCache) Get(ctx context.Context, key, value interface{}) error

Get gets item from cache and delete if expired.

func (*MapCache) Set added in v0.0.2

func (c *MapCache) Set(ctx context.Context, key, value interface{}, ttl time.Duration) error

Set sets item to cache.

type Option

type Option func(*EncodingCache)

Option configure cache.

func WithEncoding

func WithEncoding(encode encoding.Encode, decode encoding.Decode) Option

WithEncoding set ancode and decode.

Jump to

Keyboard shortcuts

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