cache

package
v0.0.0-...-3c81578 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist = errors.New("not exists")
)

vars

Functions

This section is empty.

Types

type DataBuffer

type DataBuffer struct {
	MaxElementSize int
	Expired        time.Duration
	GcInterval     time.Duration
	// contains filtered or unexported fields
}

DataBuffer is cacher for data

func NewDataBuffer

func NewDataBuffer(maxElementSize int) *DataBuffer

NewDataBuffer create a DataBuffer

func (*DataBuffer) ClearDatas

func (m *DataBuffer) ClearDatas(method string)

ClearDatas clears all method-url mapping on table tableName from cache

func (*DataBuffer) DelData

func (m *DataBuffer) DelData(method string, url string)

DelData deletes data

func (*DataBuffer) GC

func (m *DataBuffer) GC()

GC check ids lit and sql list to remove all element expired

func (*DataBuffer) GetData

func (m *DataBuffer) GetData(method string, url string) interface{}

GetData returns data according method and url from cache

func (*DataBuffer) PutData

func (m *DataBuffer) PutData(method string, url string, obj interface{}, expired ...time.Duration)

PutData puts data

func (*DataBuffer) RunGC

func (m *DataBuffer) RunGC()

RunGC run once every m.GcInterval

type MemoryStore

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

MemoryStore represents in-memory store

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new store in memory

func (*MemoryStore) Del

func (s *MemoryStore) Del(key string) error

Del deletes object

func (*MemoryStore) Get

func (s *MemoryStore) Get(key string) (interface{}, error)

Get gets object from store

func (*MemoryStore) Put

func (s *MemoryStore) Put(key string, value interface{}) error

Put puts object into store

Jump to

Keyboard shortcuts

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