cache

package
v2.0.0-...-a27a8c5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StoreNameIsEmptyErr = errors.New("store name cannot be empty")
)

Functions

This section is empty.

Types

type MemoryCacheStore

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

MemoryCacheStore implements cache store based or lru cache

func NewMemoryCacheStore

func NewMemoryCacheStore(name string, valType interface{}, size int) (cache *MemoryCacheStore, err error)

NewMemoryCacheStore new memory cache store spec size

func (*MemoryCacheStore) Contains

func (mcs *MemoryCacheStore) Contains(key string) bool

Contains check existed in a memory cache store

func (*MemoryCacheStore) Delete

func (mcs *MemoryCacheStore) Delete(key string)

Delete delete key in a memory cache store

func (*MemoryCacheStore) Get

func (mcs *MemoryCacheStore) Get(key string) (val interface{}, ok bool)

Get get a key/value from memory cache store

func (*MemoryCacheStore) Set

func (mcs *MemoryCacheStore) Set(key string, val interface{}) (ok bool)

Set a key/value to memory cache store

type RedisCacheStore

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

RedisCacheStore based redis implement cache store

func (*RedisCacheStore) Contains

func (rc *RedisCacheStore) Contains(key string) bool

Contains check key existed in redis cache store

func (*RedisCacheStore) Delete

func (rc *RedisCacheStore) Delete(key string)

Delete delete key value in redis cache store

func (*RedisCacheStore) Get

func (rc *RedisCacheStore) Get(key string) (val interface{}, ok bool)

Get value from redis cache store

func (*RedisCacheStore) Set

func (rc *RedisCacheStore) Set(key string, val interface{}) (ok bool)

Set add or update key value

type Store

type Store interface {
	Get(key string) (val interface{}, ok bool)
	Set(key string, val interface{}) (ok bool)
	Delete(key string)
	Contains(key string) bool
}

Store cache store interface

func NewRedisCacheStore

func NewRedisCacheStore(name string, valType interface{}, expired time.Duration) (store Store, err error)

NewRedisCacheStore new redis cache store

Jump to

Keyboard shortcuts

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