cache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(key string) (suc bool)

func GC

func GC()

func Get

func Get(key string) (has bool, data []byte)

func Set

func Set(key string, val []byte, life int64) (suc bool)

func SetDefaultCacheHandler

func SetDefaultCacheHandler(cache Cache)

Types

type Cache

type Cache interface {
	Set(key string, val []byte, life int64) (suc bool)
	Get(key string) (has bool, data []byte)
	Delete(key string) (suc bool)
	DeleteAll() (suc bool)
	GC()
	StartGcTimer(sec int64)
}

type Data

type Data struct {
	Key        string
	Data       []byte
	CreateTime int64
	Life       int64
}

type FileCache

type FileCache struct {
	Cache
	// contains filtered or unexported fields
}

func NewFileCache

func NewFileCache(data_dir string) *FileCache

func (*FileCache) Delete

func (cache *FileCache) Delete(key string) bool

func (*FileCache) DeleteAll

func (cache *FileCache) DeleteAll() bool

func (*FileCache) GC

func (cache *FileCache) GC()

func (*FileCache) Get

func (cache *FileCache) Get(key string) (has bool, data []byte)

func (*FileCache) Set

func (cache *FileCache) Set(key string, data []byte, life int64) (suc bool)

func (*FileCache) StartGcTimer

func (cache *FileCache) StartGcTimer(sec int64)

type NoneCache

type NoneCache struct {
	Cache
}

func NewNoneCache

func NewNoneCache() *NoneCache

func (*NoneCache) Delete

func (cache *NoneCache) Delete(key string) (suc bool)

func (*NoneCache) DeleteAll

func (cache *NoneCache) DeleteAll() (suc bool)

func (*NoneCache) GC

func (cache *NoneCache) GC()

func (*NoneCache) Get

func (cache *NoneCache) Get(key string) (has bool, data []byte)

func (*NoneCache) Set

func (cache *NoneCache) Set(key string, val []byte, life int64) bool

func (*NoneCache) StartGcTimer

func (cache *NoneCache) StartGcTimer(sec int64)

Jump to

Keyboard shortcuts

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