cache

package
v0.0.0-...-5f827c9 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Ping(ctx context.Context) error
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
	Get(ctx context.Context, key string) (string, error)
	Del(ctx context.Context, key string) error
	IncrBy(ctx context.Context, key string, value int64) error
	DecrBy(ctx context.Context, key string, value int64) error
}

Cache represents cache contract

func NewRedis

func NewRedis(client *redis.Client) Cache

NewRedis return a new redis cache

type Redis

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

Redis represents a concrete redis

func (*Redis) DecrBy

func (r *Redis) DecrBy(ctx context.Context, key string, value int64) error

DecrBy decrement a value by a key in redis

func (*Redis) Del

func (r *Redis) Del(ctx context.Context, key string) error

Del remove a key from redis

func (*Redis) Get

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

Get get a key from redis

func (*Redis) IncrBy

func (r *Redis) IncrBy(ctx context.Context, key string, value int64) error

IncrBy increment a value by a key in redis

func (*Redis) Ping

func (r *Redis) Ping(ctx context.Context) error

Ping ping the redis redis if success return nil

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key string, value interface{}, exp time.Duration) error

Set set a key in redis

Jump to

Keyboard shortcuts

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