package pool import "context" type SingleConnPool struct { pool Pooler cn *Conn stickyErr error } var _ Pooler = (*SingleConnPool)(nil) func NewSingleConnPool(pool Pooler, cn *Conn) *SingleConnPool { return &SingleConnPool{ pool: pool, cn: cn, } } func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error) { return p.pool.NewConn(ctx) } func (p *SingleConnPool) CloseConn(cn *Conn) error { return p.pool.CloseConn(cn) } func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error) { if p.stickyErr != nil { return nil, p.stickyErr } return p.cn, nil } func (p *SingleConnPool) Put(ctx context.Context, cn *Conn) {} func (p *SingleConnPool) Remove(ctx context.Context, cn *Conn, reason error) { p.cn = nil p.stickyErr = reason } func (p *SingleConnPool) Close() error { p.cn = nil p.stickyErr = ErrClosed return nil } func (p *SingleConnPool) Len() int { return 0 } func (p *SingleConnPool) IdleLen() int { return 0 } func (p *SingleConnPool) Stats() *Stats { return &Stats{} }
Related articles
redis iterator
package redis import ( "context" ) // ScanIterator is used to incrementally iterate over a collection of elements. type ScanIterator struct { cmd *ScanCmd pos int } // Err returns the last iterator error, if any. func (it *ScanIterator) Err() error
redis release
#!/bin/bash set -e help() { cat <<- EOF Usage: TAG=tag $0 Updates version in go.mod files and pushes a new brash to GitHub. VARIABLES: TAG git tag, for example, v1.0.0 EOF exit 0 } if [ -z "$TAG" ] then printf "TAG is required\n
redis once
/* Copyright 2014 The Camlistore Authors 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 http://www.apache.org/licenses/LICENS
redis reader_test
package proto_test import ( "bytes" "io" "testing" "github.com/redis/go-redis/v9/internal/proto" ) func BenchmarkReader_ParseReply_Status(b *testing.B) { benchmarkParseReply(b, "+OK\r\n", false) } func BenchmarkReader_ParseReply_Int(b *testing.B
redis cluster
package redis import ( "context" "crypto/tls" "fmt" "math" "net" "net/url" "runtime" "sort" "strings" "sync" "sync/atomic" "time" "github.com/redis/go-redis/v9/internal" "github.com/redis/go-redis/v9/internal/hashtag" "github.com/redis/g
redis race_test
package redis_test import ( "bytes" "fmt" "net" "strconv" "sync/atomic" "testing" "time" . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" "github.com/redis/go-redis/v9" ) var _ = Describe("races", func() { var client *redis.Client v
redis safe
//go:build appengine // +build appengine package util func BytesToString(b []byte) string { return string(b) } func StringToBytes(s string) []byte { return []byte(s) }
redis reader
package proto import ( "bufio" "errors" "fmt" "io" "math" "math/big" "strconv" "github.com/redis/go-redis/v9/internal/util" ) // redis resp protocol data type. const ( RespStatus = "+" // +<string>\r\n RespError = "-" // -<string>\r\n
redis universal
package redis import ( "context" "crypto/tls" "net" "time" ) // UniversalOptions information is required by UniversalClient to establish // connections. type UniversalOptions struct { // Either a single address or a seed list of host:port addresse
redis example_instrumentation_test
package redis_test import ( "context" "fmt" "net" "github.com/redis/go-redis/v9" ) type redisHook struct{} var _ redis.Hook = redisHook{} func (redisHook) DialHook(hook redis.DialHook) redis.DialHook { return func(ctx context.Context, network,