cache

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 7 Imported by: 0

README

Cache

Cache is a lib to simplify the cache connection and trace it.

Installation

go get github.com/facily-tech/go-core/cache

Documentation

Overview

Package cache help us to connect to the cache using the redis library and with tracing.

Index

Constants

View Source
const CachePrefix = "CACHE_"

CachePrefix is the prefix for the environment variables.

Variables

View Source
var ErrKeyMiss = errors.New("key does not exist")

ErrKeyMiss is the error returned when the key does not exist.

Functions

This section is empty.

Types

type Client

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

Client is the interface for the cache.

func InitCache

func InitCache() (*Client, error)

InitCache initializes the cache.

func (*Client) Del

func (r *Client) Del(ctx context.Context, keys ...string) error

Del deletes one or more keys.

func (*Client) Get

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

Get gets the value of a key.

func (*Client) Set

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

Set define the value of a key.

type ClientI

type ClientI interface {
	Set(context.Context, string, string, time.Duration) error
	Get(context.Context, string) (string, error)
	Del(context.Context, ...string) error
}

ClientI is the interface for the cache.

Jump to

Keyboard shortcuts

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