cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const Nil = cacheError("cache miss")

Nil error

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(string, interface{}) error
	Set(string, interface{}, time.Duration) error
	Forever(string, interface{}) (err error)
	Remember(string, interface{}, SetCallback, time.Duration) error
	RememberForever(string, interface{}, SetCallback) (err error)
	Delete(string) error
	Key(string) string
}

Cache interface

type Redis

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

Redis struct for use redis as cache backend

func NewRedis

func NewRedis(client *redis.Client, prefix string) *Redis

NewRedis return redis struct

func (*Redis) Delete

func (r *Redis) Delete(key string) (err error)

Delete use for delete cache item by key

func (*Redis) Forever

func (r *Redis) Forever(key string, value interface{}) (err error)

Forever use for set cache item without expiration

func (*Redis) Get

func (r *Redis) Get(key string, reply interface{}) (err error)

Get return the key of value

func (*Redis) Key

func (r *Redis) Key(key string) string

Key return the key of cache item

func (*Redis) Remember

func (r *Redis) Remember(key string, reply interface{}, fn SetCallback, expire time.Duration) (err error)

Remember use user define callback func to set cache item SetCallback should change reply value

func (*Redis) RememberForever

func (r *Redis) RememberForever(key string, reply interface{}, fn SetCallback) (err error)

RememberForever use user define callback func to set cache item without expiration SetCallback should change reply value

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}, expire time.Duration) (err error)

Set use for set cache item

type SetCallback

type SetCallback func() error

SetCallback type

Jump to

Keyboard shortcuts

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