cache

package
v0.0.0-...-eca9d05 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-2.0 Imports: 4 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(key string, pointer interface{}) error
	Set(key string, value interface{}, expires time.Duration) error
	Delete(key string) error
	DeleteMask(mask string) error
	DeleteMulti(keys ...interface{}) error
	Exists(key string) (bool, error)
}

Cache is the basic interface for cache implementations

type RedisCache

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

RedisCache is an implementation of Cache that uses Redis as a backend

func NewRedisCache

func NewRedisCache(options *RedisCacheOpts) (*RedisCache, error)

NewRedisCache creates a new cache with a redis backend

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

Delete removes data in redis by key

func (*RedisCache) DeleteMask

func (r *RedisCache) DeleteMask(mask string) error

DeleteMask removes data using KEYS masks

func (*RedisCache) DeleteMulti

func (r *RedisCache) DeleteMulti(keys ...interface{}) error

DeleteMulti removes multiple keys

func (*RedisCache) Exists

func (r *RedisCache) Exists(key string) (bool, error)

Exists performs a check whether a key exists

func (*RedisCache) Get

func (r *RedisCache) Get(key string, pointer interface{}) error

Get retrieves data from the database and then decodes it into the passed pointer.

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value interface{}, expires time.Duration) error

Set encodes passed value and sends it to redis

type RedisCacheOpts

type RedisCacheOpts struct {
	Address     string
	Database    int
	Password    string
	MaxIdle     int
	IdleTimeout time.Duration
}

RedisCacheOpts is used to pass options to NewRedisCache

Jump to

Keyboard shortcuts

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