cache

package
v1.14.7 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 10 Imported by: 141

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache added in v1.14.0

func GetCache() mc.Cache

GetCache returns the currently configured cache

func GetInt

func GetInt(key string, getFunc func() (int, error)) (int, error)

GetInt returns key value from cache with callback when no key exists in cache

func GetInt64

func GetInt64(key string, getFunc func() (int64, error)) (int64, error)

GetInt64 returns key value from cache with callback when no key exists in cache

func GetString added in v1.12.0

func GetString(key string, getFunc func() (string, error)) (string, error)

GetString returns the key value from cache with callback when no key exists in cache

func NewContext

func NewContext() error

NewContext start cache service

func Remove

func Remove(key string)

Remove key from cache

Types

type RedisCacher added in v1.13.0

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

RedisCacher represents a redis cache adapter implementation.

func (*RedisCacher) Decr added in v1.13.0

func (c *RedisCacher) Decr(key string) error

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

func (*RedisCacher) Delete added in v1.13.0

func (c *RedisCacher) Delete(key string) error

Delete deletes cached value by given key.

func (*RedisCacher) Flush added in v1.13.0

func (c *RedisCacher) Flush() error

Flush deletes all cached data.

func (*RedisCacher) Get added in v1.13.0

func (c *RedisCacher) Get(key string) interface{}

Get gets cached value by given key.

func (*RedisCacher) Incr added in v1.13.0

func (c *RedisCacher) Incr(key string) error

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

func (*RedisCacher) IsExist added in v1.13.0

func (c *RedisCacher) IsExist(key string) bool

IsExist returns true if cached value exists.

func (*RedisCacher) Put added in v1.13.0

func (c *RedisCacher) Put(key string, val interface{}, expire int64) error

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

func (*RedisCacher) StartAndGC added in v1.13.0

func (c *RedisCacher) StartAndGC(opts cache.Options) error

StartAndGC starts GC routine based on config string settings. AdapterConfig: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180,hset_name=MacaronCache,prefix=cache:

Jump to

Keyboard shortcuts

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