redisfarm

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 5 Imported by: 0

README

redis-farm

The package wraps mediocregopher/radix to support multiple REDIS servers

Documentation

Index

Constants

View Source
const RedisPUBSUBPrefix string = "CMND"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelMessage

type ChannelMessage struct {
	Tag string
	DB  int
	radix.PubSubMessage
}

type RedisFarm

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

RedisFarm holds collection of RedisStore identified by code.

func NewRedisFarm

func NewRedisFarm() *RedisFarm

NewRedisFarm cretes instance of RedisFarm.

func (*RedisFarm) Add

func (rf *RedisFarm) Add(code string, s Storer)

Add adds redis store identified by code or db.

func (*RedisFarm) ByCode

func (rf *RedisFarm) ByCode(code string) Storer

ByCode returns Storer by code.

func (*RedisFarm) ByDB

func (rf *RedisFarm) ByDB(db int) Storer

ByCode returns Storer by database number.

func (*RedisFarm) Codes

func (rf *RedisFarm) Codes() []string

Codes returns registered Storer codes.

type RedisStore

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

RedisStore wrapps redis client implementation and provides high-level API to deal with redis storage.

It's important: redis database is used as intraday data storage. Database cleans automatically by another side every next day.

func NewRedisStore

func NewRedisStore(connection string, db int, zl *zerolog.Logger) *RedisStore

NewRedisStore returns instance to RedisStore.

func (*RedisStore) Close

func (rs *RedisStore) Close()

func (*RedisStore) Connect

func (rs *RedisStore) Connect() error

func (*RedisStore) DB

func (rs *RedisStore) DB() int

func (*RedisStore) Do

func (rs *RedisStore) Do(cmd string, args ...string) error

func (*RedisStore) DoAction added in v0.2.0

func (rs *RedisStore) DoAction(a radix.Action) error

func (*RedisStore) Exists

func (rs *RedisStore) Exists(key string) (bool, error)

Exists returns true if key exists.

func (*RedisStore) Get

func (rs *RedisStore) Get(key string, val interface{}) error

func (*RedisStore) GetObject

func (rs *RedisStore) GetObject(key string, result interface{}) error

func (*RedisStore) HGet

func (rs *RedisStore) HGet(key, field string) (string, error)

func (*RedisStore) Keys

func (rs *RedisStore) Keys(pattern string, result *[]string) error

func (*RedisStore) LLen

func (rs *RedisStore) LLen(key string) (int, error)

func (*RedisStore) ListLen

func (rs *RedisStore) ListLen(key string) (int, error)

func (*RedisStore) ListRange

func (rs *RedisStore) ListRange(key string, from, to int) ([]string, error)

func (*RedisStore) Lpush

func (rs *RedisStore) Lpush(key string, element string) error

func (*RedisStore) Lrem

func (rs *RedisStore) Lrem(key, element string, cnt int) error

func (*RedisStore) MGet

func (rs *RedisStore) MGet(keys []string, val *[]string) error

func (*RedisStore) Publish

func (rs *RedisStore) Publish(code string) (bool, error)

func (*RedisStore) PublishEx

func (rs *RedisStore) PublishEx(channel string, msg string) (bool, error)

func (*RedisStore) Rpush

func (rs *RedisStore) Rpush(key string, element string) error

func (*RedisStore) Scan

func (rs *RedisStore) Scan(pattern string, result *[]string) error

Scan returns all instance names startings with "pattern".

func (*RedisStore) Set

func (rs *RedisStore) Set(key string, val string) error

func (*RedisStore) SetExt added in v0.2.0

func (rs *RedisStore) SetExt(key string, val string, opts ...string) error

func (*RedisStore) Subscribe

func (rs *RedisStore) Subscribe(tag string, dst chan ChannelMessage, channels ...string) error

type StoreFarmer

type StoreFarmer interface {
	Add(code string, s Storer)
	ByCode(code string) Storer
	ByDB(db int) Storer
	Codes() []string
}

type Storer

type Storer interface {
	Scan(pattern string, result *[]string) error
	Keys(pattern string, result *[]string) error
	Get(key string, val interface{}) error
	MGet(keys []string, result *[]string) error
	Set(key string, val string) error
	SetExt(key string, val string, opts ...string) error
	Publish(code string) (bool, error)
	PublishEx(chanel string, msg string) (bool, error)
	ListLen(key string) (int, error)
	LLen(key string) (int, error)
	ListRange(key string, from, to int) ([]string, error)
	GetObject(key string, result interface{}) error
	HGet(key, field string) (string, error)
	DB() int
	Close()
	Subscribe(tag string, dst chan ChannelMessage, channels ...string) error
	Lpush(key string, element string) error
	Rpush(key string, element string) error
	Do(cmd string, args ...string) error
	DoAction(radix.Action) error
	Lrem(key, element string, cnt int) error
	Connect() error
	Exists(key string) (bool, error)
}

Storer is and interface definition to data persistent storage.

Jump to

Keyboard shortcuts

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