nosql

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRetries = 5

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentBase

type DocumentBase struct {
	Key key.Key

	DocumentStore diface.ICollection
	// contains filtered or unexported fields
}

func (*DocumentBase) Clear

func (d *DocumentBase) Clear()

Clear clears all data on this DocumentBase.

func (*DocumentBase) Create

func (d *DocumentBase) Create() error

Create data and version in the database.

func (*DocumentBase) Delete

func (d *DocumentBase) Delete() error

Delete delete data from the database.

func (*DocumentBase) Init

func (d *DocumentBase) Init(
	data any,
	clear func(),
	store diface.ICollection,
	key key.Key,
)

Init performs an in-place initialization of a DocumentBase.

func (*DocumentBase) InitWithCache

func (d *DocumentBase) InitWithCache(
	data any,
	clear func(),
	store diface.ICollection,
	key key.Key,
	cache diface.ICache,
)

func (*DocumentBase) InitWithVersion

func (d *DocumentBase) InitWithVersion(
	data any,
	clear func(),
	store diface.ICollection,
	key key.Key,
	version noptions.Version,
)

func (*DocumentBase) Load

func (d *DocumentBase) Load() error

Load loads data and version from the database.

func (*DocumentBase) Save

func (d *DocumentBase) Save() error

Save saves data to the database. compare the version in the database and swap it.

func (*DocumentBase) Update

func (d *DocumentBase) Update(f func() bool) error

Update change the data with the given function and CAS(compare and swap) save it to the database. If the function returns false, the update will be aborted. If the update CAS fails, the function will be retried up to MaxRetries times with a randomized backoff.

type VersionCache

type VersionCache struct {
	Version any
	Data    any
}

VersionCache is a cache of a version and its data structure.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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