redis_helper

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close disconnect redis instance in tikv mode

func Init

func Init(serverAddr []string) error

Init used to init redis instance in tikv mode

func PublishShardUpdate

func PublishShardUpdate(shardID uint32, blkNum uint64, logs []*types.Log) error

PublishShardUpdate publish block update event

func PublishTxPoolUpdate

func PublishTxPoolUpdate(shardID uint32, tx types.PoolTransaction, local bool) error

PublishTxPoolUpdate publish tx pool update event

func SubscribeShardUpdate

func SubscribeShardUpdate(shardID uint32, cb func(blkNum uint64, logs []*types.Log))

SubscribeShardUpdate subscribe block update event

func SubscribeTxPoolUpdate

func SubscribeTxPoolUpdate(shardID uint32, cb func(tx types.PoolTransaction, local bool))

SubscribeTxPoolUpdate subscribe tx pool update event

Types

type BlockUpdate

type BlockUpdate struct {
	BlkNum uint64
	Logs   []*types.Log
}

BlockUpdate block update event

type LockResult added in v0.1.14

type LockResult int
const (
	LockResultSuccess LockResult
	LockResultRenewalSuccess
	LockResultFail
)

type RedisPreempt

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

func CreatePreempt

func CreatePreempt(key string) *RedisPreempt

CreatePreempt used to create a redis preempt instance

func (*RedisPreempt) LastLockStatus

func (p *RedisPreempt) LastLockStatus() bool

LastLockStatus get the last preempt status

func (*RedisPreempt) TryLock

func (p *RedisPreempt) TryLock(ttlSecond int) (result LockResult, err error)

TryLock attempt to lock the master for ttlSecond

func (*RedisPreempt) Unlock

func (p *RedisPreempt) Unlock() (bool, error)

Unlock try to release the master permission

type TxPoolUpdate

type TxPoolUpdate struct {
	Local bool
	Tx    types.PoolTransaction
	// contains filtered or unexported fields
}

TxPoolUpdate tx pool update event

func (*TxPoolUpdate) DecodeRLP

func (t *TxPoolUpdate) DecodeRLP(stream *rlp.Stream) error

DecodeRLP decode struct from binary stream

func (*TxPoolUpdate) EncodeRLP

func (t *TxPoolUpdate) EncodeRLP(w io.Writer) error

EncodeRLP encode struct to binary stream

Jump to

Keyboard shortcuts

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