redis

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package redis implements a Redis client which compatible with cache.Storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	Addrs    []string
	Password string

	// A database to be selected after connecting to server.
	// Redis Cluster ignores this value.
	DB int

	// Cluster specific flag to enable read-only commands on slave nodes.
	ReadOnly bool

	// Sentinel specific flag to set master name.
	MasterName string

	MaxRetries  int
	IdleTimeout time.Duration
}

Option represents configurable configuration for redis client.

type Redis

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

Redis is a Redis client representing a pool of zero or more underlying connections. It's saafe for concurrent use by multiple goroutines.

func New

func New(opts *Option) *Redis

New returns a client to the redis server specified by Option.

func (*Redis) Delete added in v1.2.0

func (c *Redis) Delete(key string) error

Delete deletes the item for given key.

func (*Redis) Expire

func (c *Redis) Expire(key string, expiration time.Duration) (bool, error)

Expire sets time expiration on a key

func (*Redis) Incr

func (c *Redis) Incr(key string) (int64, error)

Incr increase counter for given key.

func (*Redis) Name

func (c *Redis) Name() string

Name returns cache storage identifier.

func (*Redis) Read

func (c *Redis) Read(key string) ([]byte, error)

Read reads the item for given key.

func (*Redis) ReadMulti

func (c *Redis) ReadMulti(keys []string) (map[string][]byte, error)

ReadMulti is a batch version of Read. The returned map have exact length as provided keys. For cache miss, an empty byte will be returned.

func (*Redis) Write

func (c *Redis) Write(key string, value []byte, expiration time.Duration) error

Write writes the item for given key.

Jump to

Keyboard shortcuts

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