redis

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Store

func Store(v *Redis) func(ctx context.Context, cfg Config) (cache.Cacher[string, string], error)

Types

type Cache

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

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (string, bool, error)

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key, value string) error

type Client

type Client interface {
	Close() error
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
}

type Config

type Config struct {
	TTL time.Duration `cfg:"ttl" json:"ttl"`
}

type Connection

type Connection struct {
	ClientName string   `cfg:"client_name" json:"client_name"`
	Addr       []string `cfg:"addr"        json:"addr"`
	UserName   string   `cfg:"username"    json:"username"`
	Password   string   `cfg:"password"    json:"password"`

	TLS TLSConfig `cfg:"tls" json:"tls"`
}

type Redis

type Redis struct {
	Client
}

func New

func New(cfg Connection) (*Redis, error)

type TLSConfig

type TLSConfig struct {
	// Enabled is whether TLS is enabled.
	Enabled bool `cfg:"enabled"`
	// CertFile is the path to the client's TLS certificate.
	// Should be use with KeyFile.
	CertFile string `cfg:"cert_file"`
	// KeyFile is the path to the client's TLS key.
	// Should be use with CertFile.
	KeyFile string `cfg:"key_file"`
	// CAFile is the path to the CA certificate.
	// If empty, the server's root CA set will be used.
	CAFile string `cfg:"ca_file"`
}

TLSConfig contains options for TLS authentication.

func (TLSConfig) Generate

func (t TLSConfig) Generate() (*tls.Config, error)

Generate returns a tls.Config based on the TLSConfig.

If the TLSConfig is empty, nil is returned.

Jump to

Keyboard shortcuts

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