redis

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddress = "localhost:6379"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client[V any] struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient[V any](options Options) (*Client[V], error)

NewClient creates a new Redis client

func (Client[V]) Close

func (c Client[V]) Close() error

Close closes the client. It must be called to release any open resources.

func (Client[V]) Delete

func (c Client[V]) Delete(k string) error

Deletes a key-value pair from a storage Returns an error if given key is not valid or update operation failed

func (Client[V]) Get

func (c Client[V]) Get(k string, v *V) (found bool, err error)

Retrieves a stored value by a given key Returns a false, nil if no value have been found for a given key Returns an error if it occured during retrieving of value Expects keys that are not ""

func (Client[V]) Set

func (c Client[V]) Set(k string, v V) error

Set stores the given value for the given key. Values are automatically marshalled to JSON The key must not be ""

type Options

type Options struct {
	Address  string `toml:"address"`
	Password string `toml:"password"`
	DB       int    `toml:"db"`
}

Jump to

Keyboard shortcuts

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