cache

package
v0.0.310 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchKey = errors.New("no such key")
View Source
var NeverExpire = time.Duration(0)

Functions

This section is empty.

Types

type Client

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

func (*Client) Del

func (r *Client) Del(keys ...string) error

func (*Client) Exists

func (r *Client) Exists(keys ...string) (bool, error)

func (*Client) Expire

func (r *Client) Expire(key string, duration time.Duration) error

func (*Client) Get

func (r *Client) Get(key string) (string, error)

func (*Client) Keys

func (r *Client) Keys(pattern string) ([]string, error)

func (*Client) Set

func (r *Client) Set(key string, value string, duration time.Duration) error

type Interface

type Interface interface {
	// Keys retrieves all keys match the given pattern
	Keys(pattern string) ([]string, error)

	// Get retrieves the value of the given key, return error if key doesn't exist
	Get(key string) (string, error)

	// Set sets the value and living duration of the given key, zero duration means never expire
	Set(key string, value string, duration time.Duration) error

	// Del deletes the given key, no error returned if the key doesn't exists
	Del(keys ...string) error

	// Exists checks the existence of a give key
	Exists(keys ...string) (bool, error)

	// Expires updates object's expiration time, return err if key doesn't exist
	Expire(key string, duration time.Duration) error
}

func NewRedisClient

func NewRedisClient(option *Options, stopCh <-chan struct{}) (Interface, error)

func NewSimpleCache

func NewSimpleCache() Interface

type Options

type Options struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Password string `json:"password"`
	DB       int    `json:"db"`
}

func NewRedisOptions

func NewRedisOptions() *Options

NewRedisOptions returns options points to nowhere, because redis is not required for some components

func (*Options) AddFlags

func (r *Options) AddFlags(fs *pflag.FlagSet, s *Options)

AddFlags add option flags to command line flags, if redis-host left empty, the following options will be ignored.

func (*Options) Validate

func (r *Options) Validate() []error

Validate check options

Jump to

Keyboard shortcuts

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