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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsClient

func AsClient(client interface{}) *sql.DB

func New

func New() cache.Cache

New creates and returns a new mysql cacher.

Types

type MysqlCacher

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

MysqlCacher represents a mysql cache adapter implementation.

func (*MysqlCacher) Client

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

func (*MysqlCacher) Close

func (c *MysqlCacher) Close() error

func (*MysqlCacher) Codec

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

func (*MysqlCacher) Decr

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

Decr cached int value.

func (*MysqlCacher) Delete

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

Delete deletes cached value by given key.

func (*MysqlCacher) Flush

func (c *MysqlCacher) Flush(ctx context.Context) error

Flush deletes all cached data.

func (*MysqlCacher) Get

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

Get gets cached value by given key.

func (*MysqlCacher) Incr

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

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

func (*MysqlCacher) IsExist

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

IsExist returns true if cached value exists.

func (*MysqlCacher) Put

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

Put puts value into cache with key and expire time. If expired is 0, it will be deleted by next GC operation.

func (*MysqlCacher) SetCodec

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

func (*MysqlCacher) StartAndGC

func (c *MysqlCacher) StartAndGC(ctx context.Context, opt cache.Options) (err 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