readversioncache

package
v0.0.0-...-746fcef Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TransactConflicting

func TransactConflicting(
	database fdb.Database,
	f func(fdb.Transaction) (interface{}, error),
	onCommit func(fdb.Transaction)) (interface{}, error)

TransactConflicting is the same as db.Transact, but won't retry in case of conflicting transactions and will throw NewTokenInvalidError instead it will also execute onCommit callback if transaction commits sucessfully

Types

type AtomicMax

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

AtomicMax is used to track the max value.

func (*AtomicMax) Get

func (mt *AtomicMax) Get() int64

Get returns the current max value.

func (*AtomicMax) StoreMax

func (mt *AtomicMax) StoreMax(value int64)

StoreMax is equivalent to storing max(value, tracker.value) in the tracker

type ReadVersionCache

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

ReadVersionCache caches "safe" read versions, which are known to be

func Init

func Init(database fdb.Database, currentToken uint64, tokenKey fdb.KeyConvertible, updateInterval time.Duration) *ReadVersionCache

Init initializes the read version cache

func (*ReadVersionCache) GetReadVersion

func (cache *ReadVersionCache) GetReadVersion() (int64, error)

GetReadVersion returns the latest safe cached read version

func (*ReadVersionCache) SetReadVersion

func (cache *ReadVersionCache) SetReadVersion(version int64) error

SetReadVersion tries to set the user-proveded commit version as a new read version

type TokenInvalidError

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

TokenInvalidError happens when the lease token is no longer valid. It means that array ownership was changed

func NewTokenInvalidError

func NewTokenInvalidError(message string) TokenInvalidError

NewTokenInvalidError creates a TokenInvalidError using the provided message

func (TokenInvalidError) Error

func (e TokenInvalidError) Error() string

Jump to

Keyboard shortcuts

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