redis

package
v1.0.5 Latest Latest
Warning

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

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

Documentation

Overview

Package redis provides implementation of Go API for redis interface

Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var Nil = redis.Nil

Nil is a type alias of redis.Nil.

Functions

This section is empty.

Types

type Cmder added in v0.0.51

type Cmder = redis.Cmder

type Conn

type Conn = redis.Conn

Conn is a type alias of redis.Conn.

type Connector added in v0.0.51

type Connector interface {
	Connect(ctx context.Context) (Redis, error)
}

Connector is an interface to connect to Redis servers.

func New

func New(opts ...Option) (c Connector, err error)

New returns Connector if no error occurs.

type Deleter

type Deleter interface {
	Del(context.Context, ...string) *redis.IntCmd
}

type Getter

type Getter interface {
	Get(context.Context, string) *redis.StringCmd
	MGet(context.Context, ...string) *redis.SliceCmd
}

type Hook added in v0.0.51

type Hook = redis.Hook

type IntCmd

type IntCmd = redis.IntCmd

IntCmd is a type alias of redis.IntCmd.

type Limiter added in v1.0.0

type Limiter = redis.Limiter

type Lister

type Lister interface{}

type MockRedis added in v1.0.5

type MockRedis struct {
	TxPipelineFunc func() redis.Pipeliner
	PingFunc       func() *StatusCmd
	CloseFunc      func() error
	GetFunc        func(string) *redis.StringCmd
	MGetFunc       func(...string) *redis.SliceCmd
	DelFunc        func(keys ...string) *redis.IntCmd
}

func (*MockRedis) Close added in v1.0.5

func (m *MockRedis) Close() error

func (*MockRedis) Del added in v1.0.5

func (m *MockRedis) Del(ctx context.Context, keys ...string) *redis.IntCmd

func (*MockRedis) Get added in v1.0.5

func (m *MockRedis) Get(ctx context.Context, key string) *redis.StringCmd

func (*MockRedis) MGet added in v1.0.5

func (m *MockRedis) MGet(ctx context.Context, keys ...string) *redis.SliceCmd

func (*MockRedis) Ping added in v1.0.5

func (m *MockRedis) Ping(ctx context.Context) *StatusCmd

func (*MockRedis) TxPipeline added in v1.0.5

func (m *MockRedis) TxPipeline() redis.Pipeliner

type Option

type Option func(*redisClient) error

Option represents the functional option for redisClient.

func WithAddrs

func WithAddrs(addrs ...string) Option

WithAddrs returns the option to set the addrs.

func WithClusterSlots

func WithClusterSlots(f func(context.Context) ([]redis.ClusterSlot, error)) Option

WithClusterSlots returns the option to set the clusterSlots.

func WithDB

func WithDB(db int) Option

WithDB returns the option to set the db.

func WithDialTimeout

func WithDialTimeout(dur string) Option

WithDialTimeout returns the option to set the dialTimeout.

func WithDialer

func WithDialer(der net.Dialer) Option

WithDialer returns the option to set the dialer.

func WithDialerFunc added in v0.0.51

func WithDialerFunc(der func(ctx context.Context, addr, port string) (net.Conn, error)) Option

WithDialerFunc returns the option to set the dialer func.

func WithHooks added in v0.0.51

func WithHooks(hooks ...Hook) Option

WithHooks returns the option to add hooks.

func WithIdleCheckFrequency

func WithIdleCheckFrequency(dur string) Option

WithIdleCheckFrequency returns the option to set the idleCheckFrequency.

func WithIdleTimeout

func WithIdleTimeout(dur string) Option

WithIdleTimeout returns the option to set the idleTimeout.

func WithInitialPingDuration

func WithInitialPingDuration(dur string) Option

WithInitialPingDuration returns the option to set the initialPingDuration.

func WithInitialPingTimeLimit

func WithInitialPingTimeLimit(lim string) Option

WithInitialPingTimeLimit returns the option to set the initialPingTimeLimit.

func WithKeyPrefix

func WithKeyPrefix(prefix string) Option

WithKeyPrefix returns the option to set the keyPref.

func WithLimiter added in v1.0.0

func WithLimiter(limiter Limiter) Option

WithLimiter returns the option to limiter.

func WithMaximumConnectionAge

func WithMaximumConnectionAge(dur string) Option

WithMaximumConnectionAge returns the option to set the maxConnAge.

func WithMaximumRetryBackoff

func WithMaximumRetryBackoff(dur string) Option

WithMaximumRetryBackoff returns the option to set the maxRetryBackoff.

func WithMinimumIdleConnection

func WithMinimumIdleConnection(minIdleConns int) Option

WithMinimumIdleConnection returns the option to set the minIdleConns.

func WithMinimumRetryBackoff

func WithMinimumRetryBackoff(dur string) Option

WithMinimumRetryBackoff returns the option to set the minRetryBackoff.

func WithNetwork added in v1.0.0

func WithNetwork(network string) Option

WithNetwork returns the option to set the network like tcp or unix.

func WithOnConnectFunction

func WithOnConnectFunction(f func(context.Context, *redis.Conn) error) Option

WithOnConnectFunction returns the option to set the onConnect.

func WithPassword

func WithPassword(password string) Option

WithPassword returns the option to set the password.

func WithPoolSize

func WithPoolSize(poolSize int) Option

WithPoolSize returns the option to set the poolSize.

func WithPoolTimeout

func WithPoolTimeout(dur string) Option

WithPoolTimeout returns the option to set the poolTimeout.

func WithReadOnlyFlag

func WithReadOnlyFlag(readOnly bool) Option

WithReadOnlyFlag returns the option to set the readOnly.

func WithReadTimeout

func WithReadTimeout(dur string) Option

WithReadTimeout returns the option to set the readTimeout.

func WithRedirectLimit

func WithRedirectLimit(maxRedirects int) Option

WithRedirectLimit returns the option to set the maxRedirects.

func WithRetryLimit

func WithRetryLimit(maxRetries int) Option

WithRetryLimit returns the option to set the maxRetries.

func WithRouteByLatencyFlag

func WithRouteByLatencyFlag(routeByLatency bool) Option

WithRouteByLatencyFlag returns the option to set the routeByLatency.

func WithRouteRandomlyFlag

func WithRouteRandomlyFlag(routeRandomly bool) Option

WithRouteRandomlyFlag returns the option to set the routeRandomly.

func WithSentinelMasterName added in v1.0.0

func WithSentinelMasterName(name string) Option

WithSentinelMasterName returns the option to set the password.

func WithSentinelPassword added in v1.0.0

func WithSentinelPassword(password string) Option

WithSentinelPassword returns the option to set the password.

func WithTLSConfig

func WithTLSConfig(cfg *tls.Config) Option

WithTLSConfig returns the option to set the tlsConfig.

func WithUsername added in v1.0.0

func WithUsername(name string) Option

WithUsername returns the option to set the username.

func WithWriteTimeout

func WithWriteTimeout(dur string) Option

WithWriteTimeout returns the option to set the writeTimeout.

type Redis

type Redis interface {
	TxPipeline() redis.Pipeliner
	Ping(context.Context) *StatusCmd
	Close() error
	Lister
	Getter
	Setter
	Deleter
}

Redis is an interface to communicate with Redis servers.

type Setter

type Setter interface {
}

type StatusCmd

type StatusCmd = redis.StatusCmd

StatusCmd is a type alias of redis.StatusCmd.

type StringCmd

type StringCmd = redis.StringCmd

StringCmd is a type alias of redis.StringCmd.

Jump to

Keyboard shortcuts

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