persist

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 7 Imported by: 63

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("persist cache miss error")

Functions

This section is empty.

Types

type CacheStore

type CacheStore interface {
	// Get retrieves an item from the Cache. Returns the item or nil, and a bool indicating
	// whether the key was found.
	Get(key string, value interface{}) error

	// Set sets an item to the Cache, replacing any existing item.
	Set(key string, value interface{}, expire time.Duration) error

	// Delete removes an item from the Cache. Does nothing if the key is not in the Cache.
	Delete(key string) error
}

CacheStore is the interface of a Cache backend

type MemoryStore

type MemoryStore struct {
	Cache *cache.Cache
}

func NewMemoryStore

func NewMemoryStore(defaultExpiration time.Duration) *MemoryStore

func (*MemoryStore) Delete

func (c *MemoryStore) Delete(key string) error

func (*MemoryStore) Get

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

func (*MemoryStore) Set

func (c *MemoryStore) Set(key string, value interface{}, expire time.Duration) error

type RedisStore

type RedisStore struct {
	RedisClient *redis.Client
}

func NewRedisStore added in v0.0.2

func NewRedisStore(redisClient *redis.Client) *RedisStore

func (*RedisStore) Delete

func (store *RedisStore) Delete(key string) error

func (*RedisStore) Get

func (store *RedisStore) Get(key string, value interface{}) error

func (*RedisStore) Set

func (store *RedisStore) Set(key string, value interface{}, expire time.Duration) error

Jump to

Keyboard shortcuts

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