redis

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Connection
	Host     string
	Port     string
	Password string
	Database int
	URL      string

	// Pool settings
	MaxRetries      int
	PoolSize        int
	MinIdleConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
	ConnMaxIdleTime time.Duration

	// TLS
	UseTLS   bool
	CertFile string
	KeyFile  string
	CAFile   string

	// Common
	KeyPrefix string
	Namespace string
}

Config holds Redis specific configuration

type RedisCache

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

RedisCache implements cache using Redis

func New

func New(cfg Config) (*RedisCache, error)

New creates a new Redis cache instance

func (*RedisCache) Clear

func (rc *RedisCache) Clear(ctx context.Context) error

Clear removes all keys with the prefix

func (*RedisCache) Close

func (rc *RedisCache) Close() error

Close closes the Redis connection

func (*RedisCache) Delete

func (rc *RedisCache) Delete(ctx context.Context, key string) error

Delete removes a key

func (*RedisCache) Exists

func (rc *RedisCache) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists

func (*RedisCache) Get

func (rc *RedisCache) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a value by key

func (*RedisCache) Ping

func (rc *RedisCache) Ping(ctx context.Context) error

Ping checks if Redis is reachable

func (*RedisCache) Set

func (rc *RedisCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

Set stores a value with optional TTL

func (*RedisCache) Stats

func (rc *RedisCache) Stats(ctx context.Context) (map[string]interface{}, error)

Stats returns cache statistics

Jump to

Keyboard shortcuts

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