redis

package
v0.0.0-...-0ac9ed0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addrs    []string
	Login    string
	Password string
	DBName   int
}

type DB

type DB struct {
	Exec redis.Cmdable
	// contains filtered or unexported fields
}

func New

func New(conf Config) (*DB, error)

New creates a new DB connection

func (*DB) Cache

func (d *DB) Cache(ctx context.Context, key string, value interface{}, funcToGetData func(*cache.Item) (interface{}, error), ttl time.Duration) error

func (*DB) CacheOnce

func (d *DB) CacheOnce(cacheItem *cache.Item) error

CacheOnce makes a cache Example:

CacheOnce(&gocache.Item{
	Key:   "mykey",
	Value: obj, // destination
	Do: func(*cache.Item) (interface{}, error) {
		return &Object{
			Str: "mystring",
			Num: 42,
		}, nil
	},
})

func (*DB) Close

func (d *DB) Close() error

func (*DB) DB

func (d *DB) DB() redis.Cmdable

type IDB

type IDB interface {
	DB() redis.Cmdable
	Close() error
	CacheOnce(cacheItem *cache.Item) error
	Cache(ctx context.Context, key string, value interface{}, funcToGetData func(*cache.Item) (interface{}, error), ttl time.Duration) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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