redis

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package redis provides a Redis-backed implementation of stats.Collector. All primitives map to native Redis data structures:

  • Counter → INCR / INCRBY (string key)
  • Gauge → SET / INCR / DECR (string key)
  • Set → SADD / SISMEMBER / SCARD / SINTER (set key)
  • HLL → PFADD / PFCOUNT / PFMERGE (HyperLogLog key)
  • Timer → Sorted set (ZADD) + Lua script for percentiles

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

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

Collector implements stats.Collector backed by Redis.

func New

func New(client *redis.Client, opts ...Option) *Collector

New creates a Redis-backed collector.

func (*Collector) Close

func (c *Collector) Close() error

func (*Collector) Counter

func (c *Collector) Counter(key string) stats.Counter

func (*Collector) Flush

func (c *Collector) Flush() error

func (*Collector) Gauge

func (c *Collector) Gauge(key string) stats.Gauge

func (*Collector) HLL

func (c *Collector) HLL(key string) stats.HLL

func (*Collector) Set

func (c *Collector) Set(key string) stats.Set

func (*Collector) Timer

func (c *Collector) Timer(key string) stats.Timer

type Option

type Option func(*Collector)

Option configures the Redis collector.

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets the default context for Redis operations.

func WithKeyPrefix

func WithKeyPrefix(prefix string) Option

WithKeyPrefix sets a prefix for all Redis keys.

Jump to

Keyboard shortcuts

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