Documentation
¶
Index ¶
- Constants
- type DocumentBase
- func (d *DocumentBase) Clear()
- func (d *DocumentBase) Create() error
- func (d *DocumentBase) Delete() error
- func (d *DocumentBase) Init(data any, clear func(), store diface.ICollection, key key.Key)
- func (d *DocumentBase) InitWithCache(data any, clear func(), store diface.ICollection, key key.Key, ...)
- func (d *DocumentBase) InitWithVersion(data any, clear func(), store diface.ICollection, key key.Key, ...)
- func (d *DocumentBase) Load() error
- func (d *DocumentBase) Save() error
- func (d *DocumentBase) Update(f func() bool) error
- type VersionCache
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 ¶
VersionCache is a cache of a version and its data structure.
Click to show internal directories.
Click to hide internal directories.