redis

package
v0.0.0-...-90c44de Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidType represents error when invalid type provided
	ErrInvalidType = errors.New("invalid type provided")
)

Functions

This section is empty.

Types

type Client

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

Client represents redis client

func New

func New(cfg appconf.Redis) (*Client, error)

New creates new redis client instance

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

Delete removes value by key

func (*Client) DeleteByMatch

func (c *Client) DeleteByMatch(ctx context.Context, pattern string) error

DeleteByMatch removes value by pattern

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (string, error)

Get returns value by key. If key does not exist, returns empty string without error

func (*Client) GetStruct

func (c *Client) GetStruct(ctx context.Context, key string, value interface{}) error

GetStruct gets value by key from cache and sets value. If key does not exist, returns nil without error. If value cannot be unmarshalled, InvalidTypeError returned

func (*Client) Set

func (c *Client) Set(ctx context.Context, key, value string, ttl time.Duration) error

Set sets value for provided key with ttl. If ttl == 0, default ttl is used

func (*Client) SetStruct

func (c *Client) SetStruct(ctx context.Context, key string, value interface{}, ttl time.Duration) error

SetStruct sets struct value for provided key with ttl. If ttl == 0, default ttl is used. If value cannot be marshaled, InvalidTypeError returned

Jump to

Keyboard shortcuts

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