redis

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package redis implements a key value store (kv.Store) using redis. For more details, see https://redis.io/

Index

Constants

View Source
const Name = "redis"

Name represents redis's shorthand name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// host:port Addr.
	Addr string
	// Optional password. Must match the password specified in the
	// requirepass server configuration option.
	Password string
	// Database to be selected after connecting to the server.
	DB int
	// TLS Config to use. When set TLS will be negotiated.
	TLSConfig *tls.Config
}

Options represents options for configuring the redis store.

type Store

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

Store implements a the Store interface for redis. https://godoc.org/github.com/go-redis/redis

func New

func New(o *Options) (*Store, error)

New creates a new redis cache store. It is up to the operator to make sure that the store's path is writeable.

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close closes the client, releasing any open resources.

It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.

func (*Store) Get

func (s *Store) Get(ctx context.Context, k string) (bool, []byte, error)

Get is equivalent to Redis `GET key` command.

It returns redis.Nil error when key does not exist.

func (Store) Set

func (s Store) Set(ctx context.Context, k string, v []byte) error

Set is equivalent to redis `SET key value [expiration]` command.

Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.

Jump to

Keyboard shortcuts

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