icache

package
v0.0.0-...-2ef7dcc Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, adapter Instance)

Register makes a cache adapter available by the adapter name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type ICache

type ICache interface {
	// Get a cached value by key.
	Get(key string, val interface{}) error
	// GetMulti is a batch version of Get.
	GetMulti(keys []string, val []interface{}) error
	// Set a cached value with key and expire time.
	Put(key string, val interface{}, timeout time.Duration) error
	// Delete cached value by key.
	Delete(key string) error
	// Increment a cached int value by key, as a counter.
	Incr(key string) error
	// Decrement a cached int value by key, as a counter.
	Decr(key string) error
	// Check if a cached value exists or not.
	IsExist(key string) (bool, error)
	// Clear all cache.
	ClearAll() error
	// Start gc routine based on config string settings.
	StartAndGC(config string) error
}

func NewCache

func NewCache(adapterName, config string) (adapter ICache, err error)

NewCache creates a new cache driver by adapter name and config string. config: must be in JSON format such as {"interval":360}. Starts gc automatically.

type Instance

type Instance func() ICache

Instance is a function create a new Cache Instance

Jump to

Keyboard shortcuts

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