package internal
Import Path
github.com/redis/go-redis/v9/internal (on go.dev)
Dependency Relation
imports 13 packages, and imported by 6 packages
Package-Level Type Names (total 6)
(*DefaultLogger) Printf(ctx context.Context, format string, v ...interface{})
*DefaultLogger : Logging
FastSemaphore is a channel-based semaphore optimized for performance.
It uses a fast path that avoids timer allocation when tokens are available.
The channel is pre-filled with tokens: Acquire = receive, Release = send.
Closing the semaphore unblocks all waiting goroutines.
Performance: ~30 ns/op with zero allocations on fast path.
Fairness: Eventual fairness (no starvation) but not strict FIFO.
Acquire acquires a token, blocking if necessary until one is available.
Returns an error if the context is cancelled or the timeout expires.
Uses a fast path to avoid timer allocation when tokens are immediately available.
AcquireBlocking acquires a token, blocking indefinitely until one is available.
Available returns the number of tokens currently free (an approximation under
concurrency). Zero means every turn is taken — by an in-use connection or an
in-flight dial — so the next Acquire would block. Used as a non-blocking
capacity probe; not a synchronization primitive.
Close closes the semaphore, unblocking all waiting goroutines.
After close, all Acquire calls will receive a closed channel signal.
Len returns the current number of acquired tokens.
Release releases a token back to the semaphore.
TryAcquire attempts to acquire a token without blocking.
Returns true if successful, false if no tokens available.
func NewFastSemaphore(capacity int32) *FastSemaphore
FIFOSemaphore is a channel-based semaphore with strict FIFO ordering.
Unlike FastSemaphore, this guarantees that threads are served in the exact order they call Acquire().
The channel is pre-filled with tokens: Acquire = receive, Release = send.
Closing the semaphore unblocks all waiting goroutines.
Performance: ~115 ns/op with zero allocations (slower than FastSemaphore due to timer allocation).
Fairness: Strict FIFO ordering guaranteed by Go runtime.
Acquire acquires a token, blocking if necessary until one is available.
Returns an error if the context is cancelled or the timeout expires.
Always uses timer to guarantee FIFO ordering (no fast path).
Release releases a token back to the semaphore.
TryAcquire attempts to acquire a token without blocking.
Returns true if successful, false if no tokens available.
func NewFIFOSemaphore(capacity int32) *FIFOSemaphore
( Logging) Printf(ctx context.Context, format string, v ...interface{})
*DefaultLogger
func NewDefaultLogger(calldepth int) Logging
func github.com/redis/go-redis/v9.SetLogger(logger Logging)
LogLevelT represents the logging level
( LogLevelT) DebugOrAbove() bool
( LogLevelT) InfoOrAbove() bool
IsValid returns true if the log level is valid
String returns the string representation of the log level
( LogLevelT) WarnOrAbove() bool
LogLevelT : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer
LogLevelT : github.com/pandatix/go-abnf.ElemItf
LogLevelT : database/sql/driver.Validator
LogLevelT : expvar.Var
LogLevelT : fmt.Stringer
func github.com/redis/go-redis/v9.SetLogLevel(logLevel LogLevelT)
const LogLevelDebug
const LogLevelError
const LogLevelInfo
const LogLevelWarn
A Once will perform a successful action exactly once.
Unlike a sync.Once, this Once's func returns an error
and is re-armed on failure.
Do calls the function f if and only if Do has not been invoked
without error for this instance of Once. In other words, given
var once Once
if once.Do(f) is called multiple times, only the first call will
invoke f, even if f has a different value in each invocation unless
f returns an error. A new instance of Once is required for each
function to execute.
Do is intended for initialization that must be run exactly once. Since f
is niladic, it may be necessary to use a function literal to capture the
arguments to a function to be invoked by Do:
err := config.once.Do(func() error { return config.init(filename) })
Package-Level Functions (total 14)
FormatFloat formats a float64 to string, normalizing special values
(NaN, Inf) to lowercase for consistency with Redis RESP2 protocol.
NewDefaultLogger returns a stderr logger that attributes each line to the
frame calldepth levels up the stack.
NewFastSemaphore creates a new fast semaphore with the given capacity.
NewFIFOSemaphore creates a new FIFO semaphore with the given capacity.
func ReplaceSpaces(s string) string func ToStringSlice(val interface{}) []string
Package-Level Variables (total 2)
Logger calls Output to print to the stderr.
Arguments are handled in the manner of fmt.Print.
Swap it with redis.SetLogger; read it through Logger.Printf.
var LogLevel *atomicLogLevel
Package-Level Constants (total 10)
Calldepth values for NewDefaultLogger. Reads through Logger.Printf add one
forwarding frame (atomicLogger.Printf), so the plain default logger uses
DefaultLoggerCalldepth; wrappers that add another Printf frame (e.g.
logging's filterLogger) use FilterLoggerCalldepth.
Calldepth values for NewDefaultLogger. Reads through Logger.Printf add one
forwarding frame (atomicLogger.Printf), so the plain default logger uses
DefaultLoggerCalldepth; wrappers that add another Printf frame (e.g.
logging's filterLogger) use FilterLoggerCalldepth.
String representations of special float values.
Values are lowercase for consistency with Redis RESP2 protocol responses.
Log level constants for the entire go-redis library
Log level constants for the entire go-redis library
Log level constants for the entire go-redis library
Log level constants for the entire go-redis library
String representations of special float values.
Values are lowercase for consistency with Redis RESP2 protocol responses.
String representations of special float values.
Values are lowercase for consistency with Redis RESP2 protocol responses.
const RedisNull = ""
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |