cache

package
v2.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(adapterName string, instance Instance)

Types

type Cache

type Cache interface {
	Put(key string, val interface{}, duration time.Duration) error
	Get(key string) interface{}
	DefaultGet(key string, defaultValue interface{}) interface{}
	Delete(key string) error
	StartAndGC(config string) error
}

func NewCache

func NewCache(adapterName, config string) (Cache, error)

func NewLocalCache

func NewLocalCache() Cache

func NewRedis

func NewRedis() Cache

type Instance

type Instance func() Cache

type LocalCache

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

func (*LocalCache) DefaultGet

func (c *LocalCache) DefaultGet(key string, defaultValue interface{}) interface{}

func (*LocalCache) Delete

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

func (*LocalCache) Get

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

func (*LocalCache) Put

func (c *LocalCache) Put(key string, val interface{}, d time.Duration) error

func (*LocalCache) StartAndGC

func (c *LocalCache) StartAndGC(config string) error

config like {"defaultExpiration":1800, "cleanupInterval":1800}

type Redis

type Redis struct {
	Host     string
	Port     int
	Password string
	MaxIdle  int
	// contains filtered or unexported fields
}

func (*Redis) DefaultGet

func (r *Redis) DefaultGet(key string, defaultValue interface{}) interface{}

func (*Redis) Delete

func (r *Redis) Delete(key string) error

func (*Redis) Get

func (r *Redis) Get(key string) interface{}

func (*Redis) Put

func (r *Redis) Put(key string, val interface{}, duration time.Duration) error

func (*Redis) StartAndGC

func (r *Redis) StartAndGC(config string) error

config format like {"host":"127.0.0.1", "port":6379, "maxIdle":3, "password":""}

Jump to

Keyboard shortcuts

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