This section is empty.


This section is empty.


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.


    type Cache

    type Cache interface {
    	// get cached value by key.
    	Get(key string) interface{}
    	// GetMulti is a batch version of Get.
    	GetMulti(keys []string) []interface{}
    	// set 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
    	// increase cached int value by key, as a counter.
    	Incr(key string) error
    	// decrease cached int value by key, as a counter.
    	Decr(key string) error
    	// check if cached value exists or not.
    	IsExist(key string) bool
    	// 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 Cache, err error)

      NewCache Create a new cache driver by adapter name and config string. config need to be correct JSON as string: {"interval":360}. it will start gc automatically.

      type Instance

      type Instance func() Cache

        Instance is a function create a new Cache Instance

        Source Files


        Path Synopsis