store

package
v0.0.0-...-38a89e1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package store implements a map designed for concurrent use by splitting it into shards.

Index

Constants

View Source
const NumShards = 128

NumShards is the number of shards for each ShardMap.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStatus

type BlockStatus struct {
	IsBlocked bool

	// Frontile is a number that represents how frequently the value has been
	// hit.  Given a max number of hits x within a window of y seconds, each
	// hit will increment the FrontTile by y / x.
	FrontTile float64

	// Since is the number of seconds that have elapsed since the value was
	// blocked.
	Since float64
}

BlockStatus represents the status of a tracked value in a ShardMap.

type ShardMap

type ShardMap struct {
	Type string
	// contains filtered or unexported fields
}

ShardMap is a concurrently available map.

func NewShardMap

func NewShardMap(maxTracked int64) *ShardMap

NewShardMap returns an initialized *ShardMap.

func (*ShardMap) CleanUp

func (s *ShardMap) CleanUp(clock int32)

CleanUp accesses every shard and deletes values whose FrontTile is less than the clock.

func (*ShardMap) Get

func (s *ShardMap) Get(key interface{}) (*BlockStatus, *sync.Mutex)

Get access the map and returns a *BlockStatus and a *Mutex. If the mutex is not nil, you must unlock it when you're done. If the value you pass to Get does not exist, it will be created for you.

func (*ShardMap) Iterate

func (s *ShardMap) Iterate(f func(key interface{}, status *BlockStatus))

Iterates calls f for every key-status pair in the ShardMap.

Jump to

Keyboard shortcuts

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