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 ¶
NewShardMap returns an initialized *ShardMap.
func (*ShardMap) CleanUp ¶
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.
Click to show internal directories.
Click to hide internal directories.