kv

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FxLifeCycle

func FxLifeCycle[T Client]() fx.Option

func NewFxRepo

func NewFxRepo[T any]() fx.Option

func NewRedisFx

func NewRedisFx[T RedisConfig]() fx.Option

Types

type BinaryDataRepo

type BinaryDataRepo interface {
	Set(c context.Context, key string, value []byte) error
	SetWithExpiry(c context.Context, key string, value []byte, duration time.Duration) error
	Get(c context.Context, key string) ([]byte, error)
	ErrKeyNotFound(err error) bool
	Drop(c context.Context, key string) error
}

func NewNatsKVBinaryRepo

func NewNatsKVBinaryRepo(ctx context.Context, bucketName string, jc *nats.JetstreamClient) (BinaryDataRepo, error)

type BinaryValue

type BinaryValue struct {
	Data      []byte
	ExpiresAt time.Time
}

type Client

type Client interface {
	Connect(ctx context.Context) error
	Disconnect(ctx context.Context) error
	Set(c context.Context, key string, value []byte) error
	SetWithExpiry(c context.Context, key string, value []byte, duration time.Duration) error
	Drop(c context.Context, key string) error
	Get(c context.Context, key string) ([]byte, error)
}

func NewRedisClient

func NewRedisClient(hosts, username, password, basePrefix string) Client

type RedisClient

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

func (*RedisClient) Connect

func (c *RedisClient) Connect(ctx context.Context) error

func (*RedisClient) Disconnect

func (c *RedisClient) Disconnect(context.Context) error

func (*RedisClient) Drop

func (c *RedisClient) Drop(ctx context.Context, key string) error

func (*RedisClient) Get

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

func (*RedisClient) Set

func (c *RedisClient) Set(ctx context.Context, key string, value []byte) error

func (*RedisClient) SetWithExpiry

func (c *RedisClient) SetWithExpiry(
	ctx context.Context,
	key string,
	value []byte,
	duration time.Duration,
) error

type RedisConfig

type RedisConfig interface {
	RedisOptions() (hosts, username, password, basePrefix string)
}

type RedisConfigTyped

type RedisConfigTyped[T Client] interface {
	RedisOptions() (hosts, username, password, basePrefix string)
}

type Repo

type Repo[T any] interface {
	Set(c context.Context, key string, value T) error
	SetWithExpiry(c context.Context, key string, value T, duration time.Duration) error
	Get(c context.Context, key string) (T, error)
	ErrKeyNotFound(err error) bool
	Drop(c context.Context, key string) error
}

func NewNatsKVRepo

func NewNatsKVRepo[T any](ctx context.Context, bucketName string, jc *nats.JetstreamClient) (Repo[T], error)

func NewRepo

func NewRepo[T any](cli Client) Repo[T]

type TypedRedisClient

type TypedRedisClient[T Client] struct {
	// contains filtered or unexported fields
}

type Value

type Value[T any] struct {
	Data      T
	ExpiresAt time.Time
}

Jump to

Keyboard shortcuts

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