stores

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 8 Imported by: 0

README

Cache Stores

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStore

type CacheStore interface {
	Get(key string) (interface{}, error)
	Has(key string) bool
	Put(key string, value interface{}, expiration time.Duration)
}

CacheStore represents a way to cache

type FileStore

type FileStore struct {
	Level int
	Dir   string
}

FileStore uses the local filesystem.

func NewFileStore

func NewFileStore() FileStore

NewFileStore uses `caddy.AppDataDir()` to get a location to store the cached files.

func (FileStore) Get

func (f FileStore) Get(key string) (interface{}, error)

Get value from file.

func (FileStore) Has

func (f FileStore) Has(key string) bool

Has checks if the key exists.

func (FileStore) Put

func (f FileStore) Put(key string, value interface{}, expiration time.Duration)

Put the value in a file.

type RedisStore

type RedisStore struct {
	Client *redis.Client
}

RedisStore uses Redis

func NewRedisStore

func NewRedisStore(addr string) RedisStore

NewRedisStore creates a new RedisStore

func (RedisStore) Get

func (r RedisStore) Get(key string) (interface{}, error)

Get value from Redis.

func (RedisStore) Has

func (r RedisStore) Has(key string) bool

Has checks if the key exists.

func (RedisStore) Put

func (r RedisStore) Put(key string, value interface{}, expiration time.Duration)

Put the value in Redis.

Jump to

Keyboard shortcuts

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