-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmapstore.go
More file actions
35 lines (28 loc) · 710 Bytes
/
mapstore.go
File metadata and controls
35 lines (28 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package mapstore
const StoreDefaultSize = 1024
type Entry struct {
Key string
Value interface{}
}
type Store interface {
Set(string, interface{})
Get(string, interface{}) (interface{}, bool)
GetOrSet(string, interface{}) (interface{}, bool)
GetOrSetFunc(string, func() interface{}) (interface{}, bool)
Delete(string) bool
Update(string, func(interface{}) interface{}) bool
UpdateIfExists(string, func(interface{}) interface{}) bool
Load(chan Entry)
Save(chan<- Entry)
Len() int
ShardStats() []int
}
func NewWithSize(shardsCount int) Store {
if shardsCount > 1 {
return newStoreShard(shardsCount)
}
return newStoreSingle()
}
func New() Store {
return NewWithSize(StoreDefaultSize)
}