redis

package
v0.0.0-...-5c0bb04 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache cache adapter for redis

func NewRedis

func NewRedis(opt ...Option) *Cache

NewRedis return a opened *Cache

func (*Cache) Clear

func (r *Cache) Clear() error

Clear delete all the keys of all the existing redis

func (*Cache) Close

func (r *Cache) Close()

Close for cache

func (*Cache) Delete

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

Delete remove a redis value by key

func (*Cache) DeleteMultiple

func (r *Cache) DeleteMultiple(keys []string) error

DeleteMultiple remove multiple redis value by keys

func (*Cache) Get

func (r *Cache) Get(key string, defaultV string) string

Get return a string value from redis get

func (*Cache) GetMultiple

func (r *Cache) GetMultiple(keys []string, defaultV string) map[string]string

GetMultiple return a []string value from redis multiple get

func (*Cache) Has

func (r *Cache) Has(key string) bool

Has as from exist

func (*Cache) Set

func (r *Cache) Set(key, value string, ttl int) error

Set set a string value to redis should use expire if ttl > 0

func (*Cache) SetMultiple

func (r *Cache) SetMultiple(args map[string]string, ttl int) error

SetMultiple set multiple data to redis should use expire if ttl > 0

type Option

type Option func(*Cache)

Option option redis field

func WithHost

func WithHost(host string) Option

WithHost set host

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace set namespace

func WithPassword

func WithPassword(password string) Option

WithPassword set password

func WithPort

func WithPort(port string) Option

WithPort set port

func WithUsername

func WithUsername(username string) Option

WithUsername set username

Jump to

Keyboard shortcuts

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