Documentation

Overview

Package redis implements storage.Interface into a Redis instance.

Index

Constants

View Source
const Format = "redis"

Format is the format name registered by this package.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmder

type Cmder interface {
	Cmd(cmd string, args ...interface{}) *redis.Resp
}

Cmder is the interface required to interact with Redis.

type Option

type Option func(*Storage)

An Option configures a setting of a *Storage value.

func Prefix

func Prefix(pfx string) Option

Prefix returns an option that sets the key prefix. If this is nonempty, it is prepended to each key written to Redis.

type Storage

type Storage struct {

	// contains filtered or unexported fields

}

Storage implements storage.Interface by dispatching to a Redis client, pool, or cluster. The keys manipulated by this wrapper may be optionally given a fixed prefix, permitting multiple independent stores to co-exist on the same server.

In addition to the user-defined prefix, blobs are given the prefix "id:". For example, if the user prefix is "xx", then a blob with ID "foo" will be stored as "xx:id:foo".

func New

func New(redis Cmder, opts ...Option) *Storage

New creates a new *Storage instance that dispatches to redis.

func (*Storage) Close

func (s *Storage) Close() error

Close implements io.Closer. If the Cmder passed to New implements io.Closer, it is closed; otherwise this is a no-op.

func (*Storage) List

func (s *Storage) List(id string, f func(string) error) error

List satisfies the storage.Lister interface.

func (*Storage) Load

func (s *Storage) Load(id string) ([]byte, error)

Load satisfies part of storage.Loader.

func (*Storage) Remove

func (s *Storage) Remove(id string) error

Remove satisfies part of storage.Storer.

func (*Storage) Size

func (s *Storage) Size(id string) (int64, error)

Size satisfies part of storage.Loader.

func (*Storage) Store

func (s *Storage) Store(id string, data []byte) error

Store satisfies part of storage.Storer.

Source Files