rmap

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[K any, V any] struct {
	// contains filtered or unexported fields
}

Map data structure backed by Redis.

func NewMap

func NewMap[K any, V any](client redis.UniversalClient, namespace string, options ...Option[K, V]) *Map[K, V]

NewMap creates a new generic map. Uses JSON key/value marshalers by default.

func (*Map[K, V]) Del

func (c *Map[K, V]) Del(ctx context.Context, key K) error

Del removes a key/value from the map. Returns any errors that occurred. If the key/value does not exist, this is a no-op.

func (*Map[K, V]) Get

func (c *Map[K, V]) Get(ctx context.Context, key K) (V, bool, error)

Get retrieves a key/value from the map. Returns the potential value, whether it exists, and any errors that occurred.

func (*Map[K, V]) Set

func (c *Map[K, V]) Set(ctx context.Context, key K, value V) error

Set inserts a key/value into the map. Returns any errors that occurred.

type Option

type Option[K any, V any] func(*Options[K, V])

Option for the Map

func WithKeyMarshaler

func WithKeyMarshaler[K any, V any](marshaler marshal.Marshaler[K]) Option[K, V]

WithKeyMarshaler allows you to configure how keys are marshaled into strings.

func WithValueMarshaler

func WithValueMarshaler[K any, V any](marshaler marshal.Marshaler[V]) Option[K, V]

WithValueMarshaler allows you to configure how values are mashaled into strings.

type Options

type Options[K any, V any] struct {
	// contains filtered or unexported fields
}

Options for the Map

Jump to

Keyboard shortcuts

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