nredis

package
v0.0.0-...-7fa2d53 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySeparatorDef  string        = ":"
	KeyExpirationDef time.Duration = 0
	KeyLogEnabledDef bool          = true
)

Variables

View Source
var ErrCannotConnectToMongoDb = errors.New("cannot connect to Redis")

Redis Errors

View Source
var ErrCannotConvertFromJSON = errors.New("error converting from json")
View Source
var ErrCannotConvertToJSON = errors.New("error converting to json")

Data convert Errors

View Source
var ErrRecordAlreadyExists = errors.New("record already exists")

Records errors

View Source
var ErrRecordInserting = errors.New("error inserting the record")
View Source
var ErrRecordNotFound = errors.New("data not found")
View Source
var ErrRecordSearching = errors.New("error searching for a record")
View Source
var ErrRecordUpdating = errors.New("error updating the record")

Functions

func KeyGen

func KeyGen(separator string, part ...string) (key string)

Создание текстового ключа из состовляющих

Types

type Key

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

func CreateKey

func CreateKey(part ...string) *Key

Создание объетка Key

func NewKey

func NewKey(separator string, part ...string) *Key

Создание объетка Key

func (*Key) ClientGet

func (key *Key) ClientGet() *redis.Client

func (*Key) ClientSet

func (key *Key) ClientSet(client *redis.Client)

Инициализация redis.client

func (*Key) Exists

func (nKey *Key) Exists(ctx context.Context) (bool, error)

Проверка существования ключа

func (*Key) ExpirationSet

func (key *Key) ExpirationSet(expiration time.Duration)

func (*Key) Get

func (nKey *Key) Get(ctx context.Context) (string, error)

Чтение значения по ключу

func (*Key) GetStructJSON

func (nKey *Key) GetStructJSON(ctx context.Context, data interface{}) error

Чтение структуры по ключу. Хранение в виде JSON

func (*Key) HGetAll

func (nKey *Key) HGetAll(ctx context.Context) (map[string]string, error)

Чтение значения по ключу

func (*Key) HGetStruct

func (nKey *Key) HGetStruct(ctx context.Context, data interface{}) error

Чтение структуры по ключу

func (*Key) HSet

func (nKey *Key) HSet(ctx context.Context, values ...interface{}) error

Вставка как Ключ -> Значение

func (*Key) HSetStruct

func (nKey *Key) HSetStruct(ctx context.Context, data interface{}) error

Вставка структуры как Ключ -> Значение

func (*Key) LogDisable

func (key *Key) LogDisable()

func (*Key) LogEnable

func (key *Key) LogEnable()

func (*Key) NameGet

func (key *Key) NameGet() string

func (*Key) Set

func (nKey *Key) Set(ctx context.Context, data interface{}) error

Вставка как Ключ -> Значение

func (*Key) SetStructJSON

func (nKey *Key) SetStructJSON(ctx context.Context, value interface{}) error

Вставка структуры как Ключ -> Значение. Хранение в виде JSON

type NRedis

type NRedis struct {
	Client *redis.Client
	// contains filtered or unexported fields
}

Главный класс для Mongo

func New

func New(addr string, port int, password string, dbIdx int) *NRedis

func (*NRedis) Connect

func (nredis *NRedis) Connect(ctx context.Context) error

Соединение с Redis

func (*NRedis) Key

func (nredis *NRedis) Key(part ...string) *Key

Создание объекта ключа

Jump to

Keyboard shortcuts

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