cache

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 7 Imported by: 0

README

Cache

Redis Client with internal modifications (logs, errors...).
Supported :

  • Get,
  • List,
  • Set,
  • Delete,
  • Subscribe,
  • Listen.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNil

func IsNil(err error) bool

Types

type Access

type Access struct {
	Database int64  `yaml:"database"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type Client

type Client struct {
	Context context.Context
	Logger  hclog.Logger
	Client  *redis.Client
}

Client struct

func NewClient

func NewClient(logger hclog.Logger, config Config) *Client

NewClient Redis

func (*Client) Create

func (c *Client) Create(key string, value interface{}, ttl time.Duration) error

Create key Redis

func (*Client) Delete

func (c *Client) Delete(key string) error

Delete key Redis

func (*Client) Get

func (c *Client) Get(key string, data interface{}) error

Exist key Redis

func (*Client) Health

func (c *Client) Health() error

func (*Client) List

func (c *Client) List(pattern string, data interface{}) (map[string]string, error)

List object Redis

func (*Client) Publish

func (c *Client) Publish(channel string, message interface{}) error

func (*Client) Subscribe

func (c *Client) Subscribe(channel string, f func(d []byte) bool) error

type Config

type Config struct {
	Debug    bool     `yaml:"debug"`
	Hostname string   `yaml:"host"`
	Port     int64    `yaml:"port"`
	Timeout  *Timeout `yaml:"timeout"`
	Access   Access   `yaml:"access"`
}

type PrefixKey

type PrefixKey string

type Timeout

type Timeout struct {
	IdleTimeout        time.Duration `yaml:"idle"`
	DialTimeout        time.Duration `yaml:"dial"`
	ReadTimeout        time.Duration `yaml:"read"`
	WriteTimeout       time.Duration `yaml:"write"`
	IdleCheckFrequency time.Duration `yaml:"idleCheckFrequency"`
}

Jump to

Keyboard shortcuts

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