cache

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDBExists = errors.New("database already exists")
)

Functions

func AsClient

func AsClient(client interface{}) *nodb.Nodb

func New

func New() cache.Cache

Types

type NodbCacher

type NodbCacher struct {
	cache.GetAs
	// contains filtered or unexported fields
}

NodbCacher represents a nodb cache adapter implementation.

func (*NodbCacher) Client

func (c *NodbCacher) Client() interface{}

func (*NodbCacher) Close

func (c *NodbCacher) Close() error

func (*NodbCacher) Codec

func (c *NodbCacher) Codec() encoding.Codec

func (*NodbCacher) Decr

func (c *NodbCacher) Decr(ctx context.Context, key string) error

Decr decreases cached int-type value by given key as a counter.

func (*NodbCacher) Delete

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

Delete deletes cached value by given key.

func (*NodbCacher) Flush

func (c *NodbCacher) Flush(ctx context.Context) (err error)

Flush deletes all cached data.

func (*NodbCacher) Get

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

Get gets cached value by given key.

func (*NodbCacher) Incr

func (c *NodbCacher) Incr(ctx context.Context, key string) error

Incr increases cached int-type value by given key as a counter.

func (*NodbCacher) IsExist

func (c *NodbCacher) IsExist(ctx context.Context, key string) (bool, error)

IsExist returns true if cached value exists.

func (*NodbCacher) Put

func (c *NodbCacher) Put(ctx context.Context, key string, val interface{}, expire int64) (err error)

Put puts value into cache with key and expire time. If expired is 0, it lives forever.

func (*NodbCacher) SetCodec

func (c *NodbCacher) SetCodec(codec encoding.Codec)

func (*NodbCacher) StartAndGC

func (c *NodbCacher) StartAndGC(ctx context.Context, opt cache.Options) error

StartAndGC starts GC routine based on config string settings.

Jump to

Keyboard shortcuts

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