rdbx

package
v0.0.0-...-d025c41 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package rdbx provides a Redis-based transaction manager with distributed locking capabilities. This file contains the implementation of the Redis-based distributed locking mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDbx

func NewDbx(db *sql.DB, cache Cache) *dbx

NewDbx creates a new dbx object.

func NewTransactioner

func NewTransactioner(dbtx DBTX, redisCLient redis.UniversalClient) *tx

Types

type Cache

type Cache interface {
	Set(ctx context.Context, key string, value interface{}) error
	Append(ctx context.Context, key string, value interface{}) (int64, error)
	Get(ctx context.Context, key string) ([]byte, error)
	GetList(ctx context.Context, key string) ([]string, error)
}

type DBTX

type DBTX interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

	Begin() (*sql.Tx, error)
	Close() error
}

type RedisLockOption

type RedisLockOption interface {
	Apply(*enabledTx)
}

RedisLockOption represents an option for the Redis-based transaction with distributed locking capabilities.

func AutoUnlock

func AutoUnlock() RedisLockOption

AutoUnlock returns an option that enables automatic unlocking of the Redis-based transaction with distributed locking capabilities.

type Redsync

type Redsync interface {
	Unlock() (bool, error)
}

type Rows

type Rows struct {
	*sql.Rows
	// contains filtered or unexported fields
}

func (*Rows) Close

func (r *Rows) Close() error

func (*Rows) Next

func (r *Rows) Next() bool

func (*Rows) Scan

func (r *Rows) Scan(dest ...interface{}) error

type Transactioner

type Transactioner interface {
	EnableTx(ctx context.Context) *enabledTx
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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