autoid

package
v0.0.0-...-2cce608 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenLocalSchemaID

func GenLocalSchemaID() int64

GenLocalSchemaID generates a local schema ID.

func GetStep

func GetStep() int64

GetStep is only used by tests

Types

type Allocator

type Allocator interface {
	// Alloc allocs the next autoID for table with tableID.
	// It gets a batch of autoIDs at a time. So it does not need to access storage for each call.
	Alloc(tableID int64) (int64, error)
	// Rebase rebases the autoID base for table with tableID and the new base value.
	// If allocIDs is true, it will allocate some IDs and save to the cache.
	// If allocIDs is false, it will not allocate IDs.
	Rebase(tableID, newBase int64, allocIDs bool) error
}

Allocator is an auto increment id generator. Just keep id unique actually.

func NewAllocator

func NewAllocator(store kv.Storage, dbID int64) Allocator

NewAllocator returns a new auto increment id generator on the store.

func NewMemoryAllocator

func NewMemoryAllocator(dbID int64) Allocator

NewMemoryAllocator returns a new auto increment id generator in memory.

Jump to

Keyboard shortcuts

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