redis

package
v0.0.0-...-f56a457 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedis

func NewRedis(opt *Options) *sdk1.Client

func NewRedisFull

func NewRedisFull() *sdk2.Pool

Types

type Client

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

redis client:

func NewClient

func NewClient(opt *Options) *Client

func (*Client) Close

func (m *Client) Close() error

func (*Client) V1

func (m *Client) V1() *sdk1.Client

func (*Client) V2

func (m *Client) V2() *sdk2.Pool

type Expiration

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

func NewExpiration

func NewExpiration() *Expiration

func (*Expiration) Days

func (m *Expiration) Days(num uint32) time.Duration

以日为单位:

func (*Expiration) Hours

func (m *Expiration) Hours(num uint32) time.Duration

以小时为单位:

func (*Expiration) Minutes

func (m *Expiration) Minutes(num uint32) time.Duration

以分钟为单位:

func (*Expiration) Months

func (m *Expiration) Months(num uint32) time.Duration

以月为单位:

func (*Expiration) Seconds

func (m *Expiration) Seconds(num uint32) time.Duration

以秒为单位:

func (*Expiration) Weeks

func (m *Expiration) Weeks(num uint32) time.Duration

以周为单位:

type OptionFunc

type OptionFunc func(*Options)

fn:

type Options

type Options struct {
	//
	Name  string // redis alias name, for trace
	Proto string //
	Addr  string // host = ip + port
	Auth  string

	//
	DialTimeout  timeEx.Duration // connect max life time.
	ReadTimeout  timeEx.Duration // connect max life time.
	WriteTimeout timeEx.Duration // connect max life time.
	SlowLog      timeEx.Duration // connect max life time.
	PoolSize     int

	//
	// Active number of items allocated by the pool at a given time.
	// When zero, there is no limit on the number of items in the pool.
	Active int
	// Idle number of idle items in the pool.
	Idle int
	// Close items after remaining item for this duration. If the value
	// is zero, then item items are not closed. Applications should set
	// the timeout to a value less than the server's timeout.
	IdleTimeout timeEx.Duration
	// If WaitTimeout is set and the pool is at the Active limit, then Get() waits WatiTimeout
	// until a item to be returned to the pool before returning.
	WaitTimeout timeEx.Duration
	// If WaitTimeout is not set, then Wait effects.
	// if Wait is set true, then wait until ctx timeout, or default flase and return directly.
	Wait bool
}

func (*Options) Init

func (m *Options) Init(opts ...OptionFunc)

init default conf, update conf:

func (*Options) ToOption1

func (m *Options) ToOption1() *sdk1.Options

func (*Options) ToOption2

func (m *Options) ToOption2()

Jump to

Keyboard shortcuts

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