dgredis

package
v0.0.0-...-561878d Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 6 Imported by: 0

README

##Redis

Builtin supports using Redis as both brokers and backends, we implement NamedBroker and Backend in this component:

import dgredis // package name is prefixed 'dg' to avoid confliction with "redigo/redis" pacakge

brk, err := dgredis.NewBroker(nil)  // create a Redis-Broker with default configuration
bkd, err := dgredis.NewBackend(nil) // create a Redis-Backend with default configuration

There is nothing much to config so far. More option would be added as needed.

import dgredis

config := dgredis.DefaultRedisConfig()
cfg.Host("127.0.0.1") // host address
  .Port(123) // host port
  .Password("pwd123") // password
  .PollTimeout(1) // interval between polling, in seconds
  .MaxIdle(3) // ref(redigo): Maximum number of idle connections in the pool
  .IdleTimeout(240*time.Second) // ref(redigo): Close connections after remaining idle for this duration. If the value
                                // is zero, then idle connections are not closed. Applications should set
                                // the timeout to a value less than the server's timeout.

// create with new configuration
brk, err := dgredis.NewBroker(cfg)
bkd, err := dgredis.NewBackend(cfg)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackend

func NewBackend(cfg *RedisConfig) (v *backend, err error)

func NewBroker

func NewBroker(cfg *RedisConfig) (v *broker, err error)

Types

type RedisConfig

type RedisConfig struct {
	Host_          string        `json:"Host"`
	Port_          int           `json:"Port"`
	Password_      string        `json:"Password"`
	PollTimeout_   int           `json:"PollTimeout"`
	ListenTimeout_ int           `json:"ListenTimeout"`
	MaxIdle_       int           `json:"MaxIdle"`
	IdleTimeout_   time.Duration `json:"IdleTimeout"`
}

func DefaultRedisConfig

func DefaultRedisConfig() *RedisConfig

func (*RedisConfig) Connection

func (me *RedisConfig) Connection() string

func (*RedisConfig) GetIdleTimeout

func (me *RedisConfig) GetIdleTimeout() time.Duration

func (*RedisConfig) GetListenTimeout

func (me *RedisConfig) GetListenTimeout() int

func (*RedisConfig) GetMaxIdle

func (me *RedisConfig) GetMaxIdle() int

func (*RedisConfig) GetPassword

func (me *RedisConfig) GetPassword() string

func (*RedisConfig) GetPollTimeout

func (me *RedisConfig) GetPollTimeout() int

func (*RedisConfig) Host

func (me *RedisConfig) Host(host string) *RedisConfig

func (*RedisConfig) IdleTimeout

func (me *RedisConfig) IdleTimeout(timeout time.Duration) *RedisConfig

func (*RedisConfig) ListenTimeout

func (me *RedisConfig) ListenTimeout(timeout int) *RedisConfig

func (*RedisConfig) MaxIdle

func (me *RedisConfig) MaxIdle(count int) *RedisConfig

func (*RedisConfig) Password

func (me *RedisConfig) Password(password string) *RedisConfig

func (*RedisConfig) PollTimeout

func (me *RedisConfig) PollTimeout(timeout int) *RedisConfig

func (*RedisConfig) Port

func (me *RedisConfig) Port(port int) *RedisConfig

Jump to

Keyboard shortcuts

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