sharding

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

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shard

type Shard struct {
	sync.RWMutex // Compose from sync.RWMutex
	// contains filtered or unexported fields
}

Shard represents the data partition

type ShardedMap

type ShardedMap []*Shard

ShardedMap is a *Shards slice of pointers to some number of Shard values. Each Shard includes a map[string]interface{} that contains that shard's data, and a composed sync.RWMutex so that it can be individually locked

func NewShardedMap

func NewShardedMap(nshards int) ShardedMap

NewShardedMap is the constructor function for ShardedMap

func (ShardedMap) Get

func (m ShardedMap) Get(key string) interface{}

Get is an example of a util method attached to ShardedMap that allows users to get a value of from a shard based on key

func (ShardedMap) Keys

func (m ShardedMap) Keys() []string

Keys is used to establish locks on all of the tables concurrently.

func (ShardedMap) Set

func (m ShardedMap) Set(key string, value interface{})

Set is an example of a util method attached to ShardedMap that allows users to set a value to the shards map based on key

Jump to

Keyboard shortcuts

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