### Once.Do usage example Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Example of using Once.Do to initialize a configuration. The function literal captures the arguments to init. ```go err := config.once.Do(func() error { return config.init(filename) }) ``` -------------------------------- ### StickyConnPool.Get Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Gets the sticky connection. ```APIDOC ## StickyConnPool.Get ### Description Returns the sticky connection, creating it if needed. ### Syntax ```go func (p *StickyConnPool) Get(ctx context.Context) (*Conn, error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **\*Conn** - The sticky connection. - **error** - An error if retrieval fails. ``` -------------------------------- ### func (*StickyConnPool) Get Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Get retrieves a connection from the pool. ```APIDOC ## Method Get ### Description Get retrieves a connection from the pool. ### Signature func (p *StickyConnPool) Get(ctx context.Context) (*Conn, error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **\*Conn** - A connection from the pool. - **error** - An error if the operation fails. ``` -------------------------------- ### Once variable declaration example Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Example of declaring a Once variable. Used to ensure a function is called only once. ```go var once Once ``` -------------------------------- ### ConnPool.Get Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Gets a connection from the pool. ```APIDOC ## ConnPool.Get ### Description Retrieves a connection from the pool, creating a new one if necessary. ### Syntax ```go func (p *ConnPool) Get(ctx context.Context) (*Conn, error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **\*Conn** - A connection to use. - **error** - An error if retrieval fails. ``` -------------------------------- ### SingleConnPool.Get Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Gets the connection from the pool. ```APIDOC ## SingleConnPool.Get ### Description Returns the single connection, creating it if needed. ### Syntax ```go func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **\*Conn** - The connection. - **error** - An error if retrieval fails. ``` -------------------------------- ### StickyConnPool.NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new connection. ```APIDOC ## StickyConnPool.NewConn ### Description Creates a new connection. ### Syntax ```go func (p *StickyConnPool) NewConn(ctx context.Context) (*Conn, error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **\*Conn** - A new connection. - **error** - An error if creation fails. ``` -------------------------------- ### NewConnPool Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new ConnPool with the given options. ```APIDOC ## NewConnPool ### Description Constructs a *ConnPool using the provided options. ### Syntax ```go func NewConnPool(opt *Options) *ConnPool ``` ### Parameters - **opt** (*Options) - Required - The pool options. ### Returns - **\*ConnPool** - The new connection pool. ``` -------------------------------- ### func (*StickyConnPool) NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool NewConn creates a new connection. ```APIDOC ## Method NewConn ### Description NewConn creates a new connection. ### Signature func (p *StickyConnPool) NewConn(ctx context.Context) (*Conn, error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **\*Conn** - A new connection. - **error** - An error if the operation fails. ``` -------------------------------- ### SingleConnPool.NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new connection. ```APIDOC ## SingleConnPool.NewConn ### Description Creates a new connection. ### Syntax ```go func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **\*Conn** - A new connection. - **error** - An error if creation fails. ``` -------------------------------- ### Once.Do method signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Do calls the function f only if it has not been called successfully before. If f returns an error, the Once is re-armed and can be called again. ```go func (o *Once) Do(f func() error) error ``` -------------------------------- ### NewSingleConnPool Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new SingleConnPool. ```APIDOC ## NewSingleConnPool ### Description Constructs a *SingleConnPool that uses a single connection. ### Syntax ```go func NewSingleConnPool(pool Pooler, cn *Conn) *SingleConnPool ``` ### Parameters - **pool** (Pooler) - Required - The underlying pooler. - **cn** (*Conn) - Required - The connection to use. ### Returns - **\*SingleConnPool** - The new single-connection pool. ``` -------------------------------- ### NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new Conn object wrapping a net.Conn. ```APIDOC ## NewConn ### Description Constructs a *Conn instance from a provided net.Conn. ### Syntax ```go func NewConn(netConn net.Conn) *Conn ``` ### Parameters - **netConn** (net.Conn) - Required - The underlying network connection. ### Returns - **\*Conn** - The newly created connection wrapper. ``` -------------------------------- ### ConnPool.NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new connection. ```APIDOC ## ConnPool.NewConn ### Description Creates a new connection to the Redis server. ### Syntax ```go func (p *ConnPool) NewConn(ctx context.Context) (*Conn, error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **\*Conn** - A new connection. - **error** - An error if creation fails. ``` -------------------------------- ### ConnPool.NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new connection. ```APIDOC ## ConnPool.NewConn ### Description Creates a new connection. ### Method NewConn ### Signature func (p *ConnPool) NewConn(ctx context.Context) (*Conn, error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **conn** (*Conn) - A new connection. - **error** (error) - An error if the operation fails. ``` -------------------------------- ### NewStickyConnPool Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new StickyConnPool. ```APIDOC ## NewStickyConnPool ### Description Constructs a *StickyConnPool that sticks to a single connection from the underlying pool. ### Syntax ```go func NewStickyConnPool(pool Pooler) *StickyConnPool ``` ### Parameters - **pool** (Pooler) - Required - The underlying pooler. ### Returns - **\*StickyConnPool** - The new sticky connection pool. ``` -------------------------------- ### Once type definition Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Once performs an action exactly once, re-arming on failure. Unlike sync.Once, it returns an error and can be retried. ```go type Once struct { // contains filtered or unexported fields } ``` -------------------------------- ### Logging interface definition Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Defines the logging interface used by the package. The Printf method logs a formatted message with context. ```go type Logging interface { Printf(ctx context.Context, format string, v ...interface{}) } ``` -------------------------------- ### StickyConnPool.Put Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns a connection to the pool. ```APIDOC ## StickyConnPool.Put ### Description Returns a connection to the pool. ### Syntax ```go func (p *StickyConnPool) Put(ctx context.Context, cn *Conn) ``` ### Parameters - **ctx** (context.Context) - Required - The context. - **cn** (*Conn) - Required - The connection to return. ``` -------------------------------- ### func Seed(n int64) Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/rand Initializes the default Source to a deterministic state using the provided seed value. ```APIDOC ## func Seed ### Description Seed uses the provided seed value to initialize the default Source to a deterministic state. If Seed is not called, the generator behaves as if seeded by Seed(1). ### Signature ```go func Seed(n int64) ``` ### Parameters - **n** (int64) - Required - The seed value for the random generator. ### Returns None. ``` -------------------------------- ### SingleConnPool.Get Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns a connection from the single connection pool. ```APIDOC ## SingleConnPool.Get ### Description Returns a connection from the single connection pool. ### Method Get ### Signature func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **conn** (*Conn) - A connection. - **error** (error) - An error if the operation fails. ``` -------------------------------- ### func Shuffle(n int, swap func(i, j int)) Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/rand Pseudo-randomizes the order of elements using the provided swap function. ```APIDOC ## func Shuffle ### Description Shuffle pseudo-randomizes the order of elements. n is the number of elements. swap swaps the elements with indexes i and j. ### Signature ```go func Shuffle(n int, swap func(i, j int)) ``` ### Parameters - **n** (int) - Required - The number of elements. - **swap** (func(i, j int)) - Required - A function that swaps the elements with indexes i and j. ### Returns None. ``` -------------------------------- ### StickyConnPool.IdleLen Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the number of idle connections. ```APIDOC ## StickyConnPool.IdleLen ### Description Returns the number of idle connections in the pool. ### Syntax ```go func (p *StickyConnPool) IdleLen() int ``` ### Returns - **int** - The number of idle connections. ``` -------------------------------- ### Conn.SetNetConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Sets the underlying net.Conn. ```APIDOC ## Conn.SetNetConn ### Description Replaces the underlying network connection with the provided one. ### Syntax ```go func (cn *Conn) SetNetConn(netConn net.Conn) ``` ### Parameters - **netConn** (net.Conn) - Required - The new network connection. ``` -------------------------------- ### SingleConnPool.NewConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Creates a new connection in the single connection pool. ```APIDOC ## SingleConnPool.NewConn ### Description Creates a new connection in the single connection pool. ### Method NewConn ### Signature func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **conn** (*Conn) - A new connection. - **error** (error) - An error if the operation fails. ``` -------------------------------- ### StickyConnPool.Len Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the total number of connections. ```APIDOC ## StickyConnPool.Len ### Description Returns the total number of connections in the pool. ### Syntax ```go func (p *StickyConnPool) Len() int ``` ### Returns - **int** - The total number of connections. ``` -------------------------------- ### func (*StickyConnPool) Put Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Put returns a connection to the pool. ```APIDOC ## Method Put ### Description Put returns a connection to the pool. ### Signature func (p *StickyConnPool) Put(ctx context.Context, cn *Conn) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. - **cn** (\*Conn) - Required - The connection to return. ### Returns None ``` -------------------------------- ### ConnPool.Get Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns an existing connection from the pool or creates a new one. This is a core method for acquiring connections from the pool. ```APIDOC ## ConnPool.Get ### Description Returns an existing connection from the pool or creates a new one. ### Method Get ### Signature func (p *ConnPool) Get(ctx context.Context) (*Conn, error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **conn** (*Conn) - A connection from the pool. - **error** (error) - An error if the operation fails. ``` -------------------------------- ### SingleConnPool.Put Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns a connection to the pool. ```APIDOC ## SingleConnPool.Put ### Description Returns a connection to the pool. ### Syntax ```go func (p *SingleConnPool) Put(ctx context.Context, cn *Conn) ``` ### Parameters - **ctx** (context.Context) - Required - The context. - **cn** (*Conn) - Required - The connection to return. ``` -------------------------------- ### ConnPool.Put Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns a connection to the pool. ```APIDOC ## ConnPool.Put ### Description Returns a connection to the pool for reuse. ### Syntax ```go func (p *ConnPool) Put(ctx context.Context, cn *Conn) ``` ### Parameters - **ctx** (context.Context) - Required - The context. - **cn** (*Conn) - Required - The connection to return. ``` -------------------------------- ### ConnPool.Put Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns a connection to the pool. ```APIDOC ## ConnPool.Put ### Description Returns a connection to the pool. ### Method Put ### Signature func (p *ConnPool) Put(ctx context.Context, cn *Conn) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. - **cn** (*Conn) - Required - The connection to return. ``` -------------------------------- ### Conn.WithReader Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Executes a function with the connection's reader. ```APIDOC ## Conn.WithReader ### Description Runs the provided function with the connection's proto.Reader, respecting the given timeout. ### Syntax ```go func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error ``` ### Parameters - **ctx** (context.Context) - Required - The context. - **timeout** (time.Duration) - Required - The timeout duration. - **fn** (func(rd *proto.Reader) error) - Required - The function to execute with the reader. ### Returns - **error** - Any error from the function or timeout. ``` -------------------------------- ### Conn.WithReader Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Executes a function with the connection's reader. ```APIDOC ## Conn.WithReader ### Description Executes a function with the connection's reader. ### Method WithReader ### Signature func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error ### Parameters - **ctx** (context.Context) - Required - The context for the operation. - **timeout** (time.Duration) - Required - The timeout for the operation. - **fn** (func(*proto.Reader) error) - Required - The function to execute. ### Returns - **error** (error) - An error if the operation fails. ``` -------------------------------- ### SingleConnPool.IdleLen Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the number of idle connections. ```APIDOC ## SingleConnPool.IdleLen ### Description Returns the number of idle connections in the pool. ### Syntax ```go func (p *SingleConnPool) IdleLen() int ``` ### Returns - **int** - The number of idle connections. ``` -------------------------------- ### Struct Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/hscan Creates a StructValue for scanning Redis key-value pairs into a struct. ```APIDOC ## Struct ### Description Creates a StructValue that can be used to scan Redis key-value pairs into a struct. ### Function Signature `func Struct(dst interface{}) (StructValue, error)` ### Parameters - **dst** (interface{}) - Required - Destination struct to scan into. ### Returns - **StructValue** - A StructValue for scanning. - **error** - Returns an error if the struct is invalid. ``` -------------------------------- ### Conn.Write Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Writes bytes to the connection. ```APIDOC ## Conn.Write ### Description Writes the given byte slice to the connection. ### Syntax ```go func (cn *Conn) Write(b []byte) (int, error) ``` ### Parameters - **b** ([]byte) - Required - The data to write. ### Returns - **int** - The number of bytes written. - **error** - Any error encountered. ``` -------------------------------- ### Conn.Write Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Writes bytes to the connection. ```APIDOC ## Conn.Write ### Description Writes bytes to the connection. ### Method Write ### Signature func (cn *Conn) Write(b []byte) (int, error) ### Parameters - **b** ([]byte) - Required - The bytes to write. ### Returns - **int** - The number of bytes written. - **error** (error) - An error if the operation fails. ``` -------------------------------- ### func (*StickyConnPool) Len Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Len returns the total number of connections in the pool. ```APIDOC ## Method Len ### Description Len returns the total number of connections in the pool. ### Signature func (p *StickyConnPool) Len() int ### Parameters None ### Returns - **int** - The total number of connections. ``` -------------------------------- ### Conn.WithWriter Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Executes a function with the connection's writer. ```APIDOC ## Conn.WithWriter ### Description Runs the provided function with the connection's proto.Writer, respecting the given timeout. ### Syntax ```go func (cn *Conn) WithWriter(ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error) error ``` ### Parameters - **ctx** (context.Context) - Required - The context. - **timeout** (time.Duration) - Required - The timeout duration. - **fn** (func(wr *proto.Writer) error) - Required - The function to execute with the writer. ### Returns - **error** - Any error from the function or timeout. ``` -------------------------------- ### Conn.WithWriter Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Executes a function with the connection's writer. ```APIDOC ## Conn.WithWriter ### Description Executes a function with the connection's writer. ### Method WithWriter ### Signature func (cn *Conn) WithWriter(ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error) error ### Parameters - **ctx** (context.Context) - Required - The context for the operation. - **timeout** (time.Duration) - Required - The timeout for the operation. - **fn** (func(*proto.Writer) error) - Required - The function to execute. ### Returns - **error** (error) - An error if the operation fails. ``` -------------------------------- ### SingleConnPool.Len Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the total number of connections. ```APIDOC ## SingleConnPool.Len ### Description Returns the total number of connections in the pool. ### Syntax ```go func (p *SingleConnPool) Len() int ``` ### Returns - **int** - The total number of connections. ``` -------------------------------- ### Conn.UsedAt Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the last used time of the connection. ```APIDOC ## Conn.UsedAt ### Description Returns the last used time of the connection. ### Method UsedAt ### Signature func (cn *Conn) UsedAt() time.Time ### Returns - **time** (time.Time) - The last used time. ``` -------------------------------- ### StickyConnPool.Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns pool statistics. ```APIDOC ## StickyConnPool.Stats ### Description Returns statistics about the pool's usage. ### Syntax ```go func (p *StickyConnPool) Stats() *Stats ``` ### Returns - **\*Stats** - The pool statistics. ``` -------------------------------- ### SingleConnPool.Put Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns a connection to the single connection pool. ```APIDOC ## SingleConnPool.Put ### Description Returns a connection to the single connection pool. ### Method Put ### Signature func (p *SingleConnPool) Put(ctx context.Context, cn *Conn) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. - **cn** (*Conn) - Required - The connection to return. ``` -------------------------------- ### StickyConnPool.Reset Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Resets the sticky connection pool. ```APIDOC ## StickyConnPool.Reset ### Description Resets the pool, releasing the sticky connection and clearing state. ### Syntax ```go func (p *StickyConnPool) Reset(ctx context.Context) error ``` ### Parameters - **ctx** (context.Context) - Required - The context. ### Returns - **error** - An error if resetting fails. ``` -------------------------------- ### func (*StickyConnPool) Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Stats returns the pool statistics. ```APIDOC ## Method Stats ### Description Stats returns the pool statistics. ### Signature func (p *StickyConnPool) Stats() *Stats ### Parameters None ### Returns - **\*Stats** - A pointer to the Stats struct containing pool statistics. ``` -------------------------------- ### BadConnError.Error Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the error message. ```APIDOC ## BadConnError.Error ### Description Returns the error message for the BadConnError. ### Syntax ```go func (e BadConnError) Error() string ``` ### Returns - **string** - The error message. ``` -------------------------------- ### ScanSlice function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Signature for ScanSlice, which parses a slice of strings into a slice. ```go func ScanSlice(data []string, slice interface{}) error ``` -------------------------------- ### Conn.UsedAt Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the time the connection was last used. ```APIDOC ## Conn.UsedAt ### Description Returns the last time the connection was used. ### Syntax ```go func (cn *Conn) UsedAt() time.Time ``` ### Returns - **time.Time** - The last used time. ``` -------------------------------- ### Default Logger variable Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Default logger that writes to stderr with a 'redis: ' prefix and standard log flags. Used when no custom logger is provided. ```go var Logger Logging = &logger{ log: log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile), } ``` -------------------------------- ### ConnPool.Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns statistics about the connection pool. ```APIDOC ## ConnPool.Stats ### Description Returns statistics about the connection pool. ### Method Stats ### Signature func (p *ConnPool) Stats() *Stats ### Returns - **stats** (*Stats) - Pool statistics. ``` -------------------------------- ### IsNilReply function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Signature for IsNilReply, which detects redis.Nil of RESP2. ```go func IsNilReply(line []byte) bool ``` -------------------------------- ### Nil constant Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Defines the Nil constant as a RedisError with the message "redis: nil". Used to represent a nil reply in RESP2. ```go const Nil = RedisError("redis: nil") // nolint:errname ``` -------------------------------- ### SingleConnPool.Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns statistics about the single connection pool. ```APIDOC ## SingleConnPool.Stats ### Description Returns statistics about the single connection pool. ### Method Stats ### Signature func (p *SingleConnPool) Stats() *Stats ### Returns - **stats** (*Stats) - Pool statistics. ``` -------------------------------- ### RetryBackoff function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Calculates the backoff duration for a given retry count, bounded by minBackoff and maxBackoff. Used for retry logic. ```go func RetryBackoff(retry int, minBackoff, maxBackoff time.Duration) time.Duration ``` -------------------------------- ### func (*StickyConnPool) IdleLen Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool IdleLen returns the number of idle connections in the pool. ```APIDOC ## Method IdleLen ### Description IdleLen returns the number of idle connections in the pool. ### Signature func (p *StickyConnPool) IdleLen() int ### Parameters None ### Returns - **int** - The number of idle connections. ``` -------------------------------- ### Scan Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/hscan Scans Redis key-value map results into a destination struct using the `redis` tag. ```APIDOC ## Scan ### Description Scans the results from a key-value Redis map result set to a destination struct. The Redis keys are matched to the struct's field with the `redis` tag. ### Function Signature `func Scan(dst interface{}, keys []interface{}, vals []interface{}) error` ### Parameters - **dst** (interface{}) - Required - Destination struct to scan into. - **keys** ([]interface{}) - Required - Redis keys from the result set. - **vals** ([]interface{}) - Required - Redis values corresponding to the keys. ### Returns - **error** - Returns an error if scanning fails. ``` -------------------------------- ### BadConnError.Unwrap Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Unwraps the underlying error. ```APIDOC ## BadConnError.Unwrap ### Description Returns the underlying error that caused the bad connection. ### Syntax ```go func (e BadConnError) Unwrap() error ``` ### Returns - **error** - The underlying error. ``` -------------------------------- ### ConnPool.Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns pool statistics. ```APIDOC ## ConnPool.Stats ### Description Returns statistics about the pool's usage. ### Syntax ```go func (p *ConnPool) Stats() *Stats ``` ### Returns - **\*Stats** - The pool statistics. ``` -------------------------------- ### SingleConnPool.Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns pool statistics. ```APIDOC ## SingleConnPool.Stats ### Description Returns statistics about the pool's usage. ### Syntax ```go func (p *SingleConnPool) Stats() *Stats ``` ### Returns - **\*Stats** - The pool statistics. ``` -------------------------------- ### SingleConnPool.IdleLen Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the number of idle connections in the single connection pool. ```APIDOC ## SingleConnPool.IdleLen ### Description Returns the number of idle connections in the single connection pool. ### Method IdleLen ### Signature func (p *SingleConnPool) IdleLen() int ### Returns - **int** - The number of idle connections. ``` -------------------------------- ### RESP protocol type constants Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Defines the byte constants for each RESP protocol data type, including status, error, string, int, nil, float, bool, blob error, verbatim, big int, array, map, set, attribute, and push. Each constant is annotated with the corresponding wire format. ```go const ( RespStatus = '+' // +\r\n RespError = '-' // -\r\n RespString = '$' // $\r\n\r\n RespInt = ':' // :\r\n RespNil = '_' // _\r\n RespFloat = ',' // ,\r\n (golang float) RespBool = '#' // true: #t\r\n false: #f\r\n RespBlobError = '!' // !\r\n\r\n RespVerbatim = '=' // =\r\nFORMAT:\r\n RespBigInt = '(' // (\r\n RespArray = '*' // *\r\n... (same as resp2) RespMap = '%' // %\r\n(key)\r\n(value)\r\n... (golang map) RespSet = '~' // ~\r\n... (same as Array) RespAttr = '|' // |\r\n(key)\r\n(value)\r\n... + command reply RespPush = '>' // >\r\n... (same as Array) ) ``` -------------------------------- ### Conn.Close Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Closes the connection. ```APIDOC ## Conn.Close ### Description Closes the underlying network connection. ### Syntax ```go func (cn *Conn) Close() error ``` ### Returns - **error** - An error if closing fails. ``` -------------------------------- ### Conn.Close Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Closes the connection. ```APIDOC ## Conn.Close ### Description Closes the connection. ### Method Close ### Signature func (cn *Conn) Close() error ### Returns - **error** (error) - An error if the operation fails. ``` -------------------------------- ### Conn.SetNetConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Sets the underlying network connection. ```APIDOC ## Conn.SetNetConn ### Description Sets the underlying network connection. ### Method SetNetConn ### Signature func (cn *Conn) SetNetConn(netConn net.Conn) ### Parameters - **netConn** (net.Conn) - Required - The new network connection. ``` -------------------------------- ### ConnPool.IdleLen Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the number of idle connections in the pool. ```APIDOC ## ConnPool.IdleLen ### Description Returns the count of idle connections currently in the pool. ### Syntax ```go func (p *ConnPool) IdleLen() int ``` ### Returns - **int** - The number of idle connections. ``` -------------------------------- ### ConnPool.IdleLen Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the number of idle connections in the pool. ```APIDOC ## ConnPool.IdleLen ### Description Returns the number of idle connections in the pool. ### Method IdleLen ### Signature func (p *ConnPool) IdleLen() int ### Returns - **int** - The number of idle connections. ``` -------------------------------- ### func Perm(n int) []int Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/rand Returns a pseudo-random permutation of the integers [0,n) as a slice of n ints. ```APIDOC ## func Perm ### Description Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n). ### Signature ```go func Perm(n int) []int ``` ### Parameters - **n** (int) - Required - The number of elements in the permutation. ### Returns - **[]int** - A slice containing a pseudo-random permutation of the integers [0,n). ``` -------------------------------- ### func (*StickyConnPool) Reset Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Reset resets the pool. ```APIDOC ## Method Reset ### Description Reset resets the pool. ### Signature func (p *StickyConnPool) Reset(ctx context.Context) error ### Parameters - **ctx** (context.Context) - Required - The context for the operation. ### Returns - **error** - An error if the reset operation fails. ``` -------------------------------- ### AppendArg function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Appends a formatted representation of v to the byte slice b. Used internally for building command arguments. ```go func AppendArg(b []byte, v interface{}) []byte ``` -------------------------------- ### func Atoi(b []byte) (int, error) Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/util Converts a byte slice to an integer. Returns the integer value and an error if conversion fails. ```APIDOC ## func Atoi ### Description Converts a byte slice to an integer. ### Signature ```go func Atoi(b []byte) (int, error) ``` ### Parameters - **b** ([]byte) - Required - The byte slice to convert. ### Returns - **int** - The converted integer value. - **error** - An error if the conversion fails. ``` -------------------------------- ### BadConnError.Unwrap Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Unwraps the underlying error of a bad connection error. ```APIDOC ## BadConnError.Unwrap ### Description Unwraps the underlying error of a bad connection error. ### Method Unwrap ### Signature func (e BadConnError) Unwrap() error ### Returns - **error** (error) - The underlying error. ``` -------------------------------- ### StickyConnPool.Close Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Closes the sticky connection pool. ```APIDOC ## StickyConnPool.Close ### Description Closes the sticky connection pool, releasing the sticky connection. ### Syntax ```go func (p *StickyConnPool) Close() error ``` ### Returns - **error** - An error if closing fails. ``` -------------------------------- ### ToLower function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Converts a string to lowercase. Utility function for internal use. ```go func ToLower(s string) string ``` -------------------------------- ### BadConnError.Error Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the error message for a bad connection error. ```APIDOC ## BadConnError.Error ### Description Returns the error message for a bad connection error. ### Method Error ### Signature func (e BadConnError) Error() string ### Returns - **string** - The error message. ``` -------------------------------- ### type Stats Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Stats contains pool state information and accumulated stats. ```APIDOC ## Type Stats ### Description Stats contains pool state information and accumulated stats. ### Fields - **TotalConns** (uint32) - number of total connections in the pool - **IdleConns** (uint32) - number of idle connections in the pool - **StaleConns** (uint32) - number of stale connections removed from the pool ``` -------------------------------- ### ConnPool.Len Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the total number of connections in the pool. ```APIDOC ## ConnPool.Len ### Description Returns the total count of connections in the pool, including idle and active. ### Syntax ```go func (p *ConnPool) Len() int ``` ### Returns - **int** - The total number of connections. ``` -------------------------------- ### ConnPool.Len Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the total number of connections in the pool. ```APIDOC ## ConnPool.Len ### Description Returns the total number of connections in the pool. ### Method Len ### Signature func (p *ConnPool) Len() int ### Returns - **int** - The total number of connections. ``` -------------------------------- ### StructValue.Scan Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/hscan Scans a single key-value pair into the struct. ```APIDOC ## StructValue.Scan ### Description Scans a single key-value pair into the struct. ### Function Signature `func (s StructValue) Scan(key string, value string) error` ### Parameters - **key** (string) - Required - Redis key. - **value** (string) - Required - Redis value. ### Returns - **error** - Returns an error if scanning fails. ``` -------------------------------- ### func IsNilReply(line []byte) bool Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Detects if a RESP2 reply line represents a nil value (redis.Nil). ```APIDOC ## func IsNilReply(line []byte) bool ### Description IsNilReply detects redis.Nil of RESP2. ### Function Signature func IsNilReply(line []byte) bool ### Parameters - **line** ([]byte) - Required - The reply line to check. ### Returns - **bool** - True if the line represents a nil reply, false otherwise. ``` -------------------------------- ### func (*StickyConnPool) Close Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Close closes the sticky connection pool. ```APIDOC ## Method Close ### Description Close closes the sticky connection pool. ### Signature func (p *StickyConnPool) Close() error ### Parameters None ### Returns - **error** - An error if the close operation fails. ``` -------------------------------- ### Scan function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Signature for Scan, which parses bytes `b` to `v` with appropriate type. ```go func Scan(b []byte, v interface{}) error ``` -------------------------------- ### func (*StickyConnPool) CloseConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool CloseConn closes the given connection. ```APIDOC ## Method CloseConn ### Description CloseConn closes the given connection. ### Signature func (p *StickyConnPool) CloseConn(cn *Conn) error ### Parameters - **cn** (\*Conn) - Required - The connection to close. ### Returns - **error** - An error if the close operation fails. ``` -------------------------------- ### func BytesToString(b []byte) string Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/util Converts a byte slice to a string. This is a convenience function for string(b). ```APIDOC ## func BytesToString ### Description Converts a byte slice to a string. ### Signature ```go func BytesToString(b []byte) string ``` ### Parameters - **b** ([]byte) - Required - The byte slice to convert. ### Returns - **string** - The resulting string. ``` -------------------------------- ### StickyConnPool.CloseConn Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Closes a connection in the pool. ```APIDOC ## StickyConnPool.CloseConn ### Description Closes the given connection and removes it from the pool. ### Syntax ```go func (p *StickyConnPool) CloseConn(cn *Conn) error ``` ### Parameters - **cn** (*Conn) - Required - The connection to close. ### Returns - **error** - An error if closing fails. ``` -------------------------------- ### SingleConnPool.Len Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Returns the total number of connections in the single connection pool. ```APIDOC ## SingleConnPool.Len ### Description Returns the total number of connections in the single connection pool. ### Method Len ### Signature func (p *SingleConnPool) Len() int ### Returns - **int** - The total number of connections. ``` -------------------------------- ### Conn.SetUsedAt Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Sets the time the connection was last used. ```APIDOC ## Conn.SetUsedAt ### Description Updates the timestamp indicating when the connection was last used. ### Syntax ```go func (cn *Conn) SetUsedAt(tm time.Time) ``` ### Parameters - **tm** (time.Time) - Required - The time to set as the last used time. ``` -------------------------------- ### StickyConnPool.Remove Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Removes a connection from the pool. ```APIDOC ## StickyConnPool.Remove ### Description Removes a connection from the pool. ### Syntax ```go func (p *StickyConnPool) Remove(ctx context.Context, cn *Conn, reason error) ``` ### Parameters - **ctx** (context.Context) - Required - The context. - **cn** (*Conn) - Required - The connection to remove. - **reason** (error) - Required - The reason for removal. ``` -------------------------------- ### func ParseUint(b []byte, base int, bitSize int) (uint64, error) Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/util Parses a byte slice as an unsigned integer with the specified base and bit size. Returns the uint64 value and an error if parsing fails. ```APIDOC ## func ParseUint ### Description Parses a byte slice as an unsigned integer. ### Signature ```go func ParseUint(b []byte, base int, bitSize int) (uint64, error) ``` ### Parameters - **b** ([]byte) - Required - The byte slice to parse. - **base** (int) - Required - The base (0, 2, 8, 10, 16) for the integer. - **bitSize** (int) - Required - The bit size of the integer (0, 8, 16, 32, 64). ### Returns - **uint64** - The parsed unsigned integer value. - **error** - An error if parsing fails. ``` -------------------------------- ### func NewStickyConnPool Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool NewStickyConnPool creates a new StickyConnPool with the given underlying pool. ```APIDOC ## Function NewStickyConnPool ### Description NewStickyConnPool creates a new StickyConnPool with the given underlying pool. ### Signature func NewStickyConnPool(pool Pooler) *StickyConnPool ### Parameters - **pool** (Pooler) - Required - The underlying pooler to wrap. ### Returns - **\*StickyConnPool** - A new StickyConnPool instance. ``` -------------------------------- ### ConnPool.Filter Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Applies a filter function to all connections in the pool. ```APIDOC ## ConnPool.Filter ### Description Applies a filter function to all connections in the pool. ### Method Filter ### Signature func (p *ConnPool) Filter(fn func(*Conn) bool) error ### Parameters - **fn** (func(*Conn) bool) - Required - The filter function. ### Returns - **error** (error) - An error if the operation fails. ``` -------------------------------- ### func (*StickyConnPool) Remove Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Remove removes a connection from the pool. ```APIDOC ## Method Remove ### Description Remove removes a connection from the pool. ### Signature func (p *StickyConnPool) Remove(ctx context.Context, cn *Conn, reason error) ### Parameters - **ctx** (context.Context) - Required - The context for the operation. - **cn** (\*Conn) - Required - The connection to remove. - **reason** (error) - Required - The reason for removal. ### Returns None ``` -------------------------------- ### type Reader Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Reader provides methods to read and parse RESP protocol data from an underlying io.Reader. ```APIDOC ## type Reader ### Description Reader provides methods to read and parse RESP protocol data from an underlying io.Reader. ### Constructor - **func NewReader(rd io.Reader) *Reader** - Creates a new Reader. ### Methods - **func (r *Reader) Buffered() int** - Returns the number of bytes currently buffered. - **func (r *Reader) Discard(line []byte) (err error)** - Discards the given line. - **func (r *Reader) DiscardNext() error** - Discards the next reply. - **func (r *Reader) Peek(n int) ([]byte, error)** - Peeks at the next n bytes without consuming. - **func (r *Reader) PeekReplyType() (byte, error)** - Peeks at the reply type byte. - **func (r *Reader) ReadArrayLen() (int, error)** - Reads the length of an array reply. - **func (r *Reader) ReadBool() (bool, error)** - Reads a boolean reply. - **func (r *Reader) ReadFixedArrayLen(fixedLen int) error** - Reads a fixed-length array. - **func (r *Reader) ReadFixedMapLen(fixedLen int) error** - Reads a fixed-length map. - **func (r *Reader) ReadFloat() (float64, error)** - Reads a float reply. - **func (r *Reader) ReadInt() (int64, error)** - Reads an integer reply. - **func (r *Reader) ReadLine() ([]byte, error)** - Reads a line. - **func (r *Reader) ReadMapLen() (int, error)** - Reads the length of a map reply. - **func (r *Reader) ReadReply() (interface{}, error)** - Reads a full reply. - **func (r *Reader) ReadSlice() ([]interface{}, error)** - Reads a slice reply. - **func (r *Reader) ReadString() (string, error)** - Reads a string reply. - **func (r *Reader) Reset(rd io.Reader)** - Resets the reader with a new underlying reader. ``` -------------------------------- ### func Slot(key string) int Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/hashtag Slot returns a consistent slot number between 0 and 16383 for any given string key. It uses the key's hashtag to compute the slot. ```APIDOC ## func Slot(key string) int ### Description Slot returns a consistent slot number between 0 and 16383 for any given string key. It uses the key's hashtag to compute the slot. ### Function Signature `func Slot(key string) int` ### Parameters - **key** (string) - The key for which to compute the slot. ### Returns - **int** - The slot number between 0 and 16383. ``` -------------------------------- ### type Writer Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/proto Writer provides methods to write RESP protocol data to an underlying writer. ```APIDOC ## type Writer ### Description Writer provides methods to write RESP protocol data to an underlying writer. ### Constructor - **func NewWriter(wr writer) *Writer** - Creates a new Writer. ### Methods - **func (w *Writer) WriteArg(v interface{}) error** - Writes a single argument. - **func (w *Writer) WriteArgs(args []interface{}) error** - Writes multiple arguments. ``` -------------------------------- ### Sleep function signature Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal Sleeps for the given duration, but returns early if the context is done. Useful for cancellable sleeps. ```go func Sleep(ctx context.Context, dur time.Duration) error ``` -------------------------------- ### SingleConnPool.Close Source: https://pkg.go.dev/github.com/go-redis/redis/v9/internal/pool Closes the single connection pool. ```APIDOC ## SingleConnPool.Close ### Description Closes the single connection pool. ### Syntax ```go func (p *SingleConnPool) Close() error ``` ### Returns - **error** - An error if closing fails. ```