redis

package
v0.0.0-...-0f16109 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

func New

func New(cfg Config, logger *slog.Logger) *Adapter

New creates a new instance of Redis Adapter.

func (*Adapter) Client

func (a *Adapter) Client() *redis.Client

Client get redis client.

func (*Adapter) Close

func (a *Adapter) Close() error

Close redis connections.

func (*Adapter) Decr

func (a *Adapter) Decr(ctx context.Context, key string) (int64, error)

Decr implement the Decr method of the cachemanager.CacheClient interface for Redis.

func (*Adapter) Delete

func (a *Adapter) Delete(ctx context.Context, keys ...string) error

Delete implement the Delete method of the cachemanager.CacheClient interface for Redis.

func (*Adapter) Expire

func (a *Adapter) Expire(ctx context.Context, key string, expiration time.Duration) error

Expire implement the Expire method of the cachemanager.CacheClient interface for Redis.

func (*Adapter) Get

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

Get implement the Get method of the cachemanager.CacheClient interface for Redis. It translates redis.Nil error into cachemanager.ErrKeyNotFound.

func (*Adapter) GetTTL

func (a *Adapter) GetTTL(ctx context.Context, key string) (time.Duration, error)

GetTTL implement the GetTTL method of the cachemanager.CacheClient interface for Redis. It translates Redis's TTL return values (-1 for persistent, -2 for not found) into the generic time.Duration and cachemanager.ErrKeyNotFound.

func (*Adapter) Incr

func (a *Adapter) Incr(ctx context.Context, key string) (int64, error)

Incr implement the Incr method of the cachemanager.CacheClient interface for Redis.

func (*Adapter) MGet

func (a *Adapter) MGet(ctx context.Context, keys ...string) ([]interface{}, error)

MGet implement the MGet method of the cachemanager.CacheClient interfcae for redis.

func (*Adapter) Set

func (a *Adapter) Set(ctx context.Context, key string, value []byte, expiration time.Duration) error

Set implement the Set method of the cachemanager.CacheClient interface for Redis.

type Config

type Config struct {
	Host     string `koanf:"host"`
	Port     int    `koanf:"port"`
	Password string `koanf:"password"`
	DB       int    `koanf:"db"`
}

Jump to

Keyboard shortcuts

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