xidmap

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: AGPL-3.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// NumShards controls the number of shards the XidMap is broken into. More
	// shards reduces lock contention.
	NumShards int
	// LRUSize controls the total size of the LRU cache. The LRU is split
	// between all shards, so with 4 shards and an LRUSize of 100, each shard
	// receives 25 LRU slots.
	LRUSize int
}

Options controls the performance characteristics of the XidMap.

type XidMap

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

XidMap allocates and tracks mappings between Xids and Uids in a threadsafe manner. It's memory friendly because the mapping is stored on disk, but fast because it uses an LRU cache.

func New

func New(kv *badger.DB, zero *grpc.ClientConn, opt Options) *XidMap

New creates an XidMap with given badger and uid provider.

func (*XidMap) AllocateUid

func (m *XidMap) AllocateUid() uint64

AllocateUid gives a single uid without creating an xid to uid mapping.

func (*XidMap) AssignUid

func (m *XidMap) AssignUid(xid string) (uid uint64, isNew bool)

AssignUid creates new or looks up existing XID to UID mappings.

func (*XidMap) EvictAll added in v1.0.2

func (m *XidMap) EvictAll()

Jump to

Keyboard shortcuts

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