mcache

package
v0.4.74 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetDefault = func() Cacheable {
	if Default != nil {
		return Default
	}
	panic("big cache not initialize")
}

Functions

func Close

func Close() error

func Delete

func Delete(key string) error

func Get

func Get(key string) (string, error)

func GetBytes

func GetBytes(key string) ([]byte, error)

func GetBytesFunc

func GetBytesFunc(key string, fun func() []byte) ([]byte, error)

func GetFunc

func GetFunc(key string, fun func() []byte) (string, error)

func GetJson

func GetJson(key string, dest any) (any, error)

func GetJsonFunc

func GetJsonFunc(key string, dest any, fun func() []byte) (any, error)

func InitDefault

func InitDefault(config bigcache.Config, ctx context.Context)

func InitDefault2

func InitDefault2(ctx context.Context)

func InitDefault2WithBlot

func InitDefault2WithBlot(boltDB *mbolt.Bolt, bucket string, ctx context.Context)

func InitDefaultWithBlot

func InitDefaultWithBlot(boltDB *mbolt.Bolt, bucket string, config bigcache.Config, ctx context.Context)

func IsError

func IsError(err error) bool

func Set

func Set(key string, value string) error

func SetBytes

func SetBytes(key string, value []byte) error

func SetJson

func SetJson(key string, dest any) error

Types

type BoltCacheable

type BoltCacheable struct {
	Cache      Cacheable
	Bolt       *mbolt.Bolt
	BucketName string
}

func (*BoltCacheable) Close

func (ce *BoltCacheable) Close() error

func (*BoltCacheable) Delete

func (ce *BoltCacheable) Delete(key string) error

func (*BoltCacheable) Get

func (ce *BoltCacheable) Get(key string) (string, error)

func (*BoltCacheable) GetBytes

func (ce *BoltCacheable) GetBytes(key string) ([]byte, error)

func (*BoltCacheable) GetBytesFunc

func (ce *BoltCacheable) GetBytesFunc(key string, fun func() []byte) ([]byte, error)

func (*BoltCacheable) GetFunc

func (ce *BoltCacheable) GetFunc(key string, fun func() []byte) (string, error)

func (*BoltCacheable) GetJson

func (ce *BoltCacheable) GetJson(key string, dest any) (any, error)

func (*BoltCacheable) GetJsonFunc

func (ce *BoltCacheable) GetJsonFunc(key string, dest any, fun func() []byte) (any, error)

func (*BoltCacheable) Set

func (ce *BoltCacheable) Set(key string, value string) error

func (*BoltCacheable) SetBytes

func (ce *BoltCacheable) SetBytes(key string, value []byte) error

func (*BoltCacheable) SetJson

func (ce *BoltCacheable) SetJson(key string, dest any) error

type Cacheable

type Cacheable interface {
	Get(key string) (string, error)
	GetFunc(key string, fun func() []byte) (string, error)
	GetBytes(key string) ([]byte, error)
	GetBytesFunc(key string, fun func() []byte) ([]byte, error)
	Set(key string, value string) error
	SetBytes(key string, value []byte) error
	Delete(key string) error
	GetJsonFunc(key string, dest any, fun func() []byte) (any, error)
	GetJson(key string, dest any) (any, error)
	SetJson(key string, dest any) error
	Close() error
}
var Default Cacheable

func InitCache

func InitCache(config bigcache.Config, ctx context.Context) Cacheable

func InitCache2

func InitCache2(ctx context.Context) Cacheable

func InitCache2WithBlot

func InitCache2WithBlot(boltDB *mbolt.Bolt, bucket string, ctx context.Context) Cacheable

func InitCacheWithBlot

func InitCacheWithBlot(boltDB *mbolt.Bolt, bucket string, config bigcache.Config, ctx context.Context) Cacheable

type MemoryCacheable

type MemoryCacheable struct {
	BigCache *bigcache.BigCache
}

func (*MemoryCacheable) Close

func (ce *MemoryCacheable) Close() error

func (*MemoryCacheable) Delete

func (ce *MemoryCacheable) Delete(key string) error

func (*MemoryCacheable) Get

func (ce *MemoryCacheable) Get(key string) (string, error)

func (*MemoryCacheable) GetBytes

func (ce *MemoryCacheable) GetBytes(key string) ([]byte, error)

func (*MemoryCacheable) GetBytesFunc

func (ce *MemoryCacheable) GetBytesFunc(key string, fun func() []byte) ([]byte, error)

func (*MemoryCacheable) GetFunc

func (ce *MemoryCacheable) GetFunc(key string, fun func() []byte) (string, error)

func (*MemoryCacheable) GetJson

func (ce *MemoryCacheable) GetJson(key string, dest any) (any, error)

func (*MemoryCacheable) GetJsonFunc

func (ce *MemoryCacheable) GetJsonFunc(key string, dest any, fun func() []byte) (any, error)

func (*MemoryCacheable) Set

func (ce *MemoryCacheable) Set(key string, value string) error

func (*MemoryCacheable) SetBytes

func (ce *MemoryCacheable) SetBytes(key string, value []byte) error

func (*MemoryCacheable) SetJson

func (ce *MemoryCacheable) SetJson(key string, dest any) error

Jump to

Keyboard shortcuts

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