rdb

package
v0.0.0-...-59cac3b Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNil = errors.New("db.go: nil returned")

Functions

func Bytes

func Bytes(reply interface{}, err error) ([]byte, error)

Copied from github.com/redigo/redis Bytes is a helper that converts a command reply to a slice of bytes. If err is not equal to nil, then Bytes returns nil, err. Otherwise Bytes converts the reply to a slice of bytes as follows:

Reply type      Result
bulk string     reply, nil
simple string   []byte(reply), nil
nil             nil, ErrNil
other           nil, error

Types

type Database

type Database struct {
	Rejson  *rejson.Handler
	Goredis *goredis.Client
}

Define Database data as struct

func NewDatabase

func NewDatabase(redisAddr string, dbNum int) Database

Create new database and return populated struct

func (Database) Flush

func (db Database) Flush() error

Flush database using Goredis

func (Database) GetJsonData

func (db Database) GetJsonData(key string, path string) ([]uint8, error)

Get json data for key at path.

Returns marshalled json byte array so make sure to unmarshall externally into an appropriate struct.

func (Database) SetJsonData

func (db Database) SetJsonData(key string, path string, data interface{}) error

Set json data for key at path.

type InteractiveDB

type InteractiveDB interface {
	SetJsonData(key string, path string, data interface{}) error
	GetJsonData(key string, path string) ([]uint8, error)
	Flush() error
}

Define InteractiveDB behaviour as interface

Jump to

Keyboard shortcuts

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