kv

package
v0.0.0-...-fa7900d Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNatsKvRepoFx

func NewNatsKvRepoFx[T any](bucketName string) 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)
}

type Entry

type Entry[T any] struct {
	Key   string
	Value T
}

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)
	Keys(c context.Context, pattern string) ([]string, error)
	List(c context.Context, pattern string) ([]T, error)
	Entries(c context.Context, pattern string) ([]Entry[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)

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