Documentation ¶
Index ¶
- Constants
- Variables
- func Zip(dst io.Writer, src string) error
- func ZipToFile(dst, src string) error
- type Fnv32Hash
- type IDWorker
- type IHash
- type IterCb
- type RemoveCb
- type ShardLockMaps
- func (slm ShardLockMaps) Clear()
- func (slm ShardLockMaps) Count() int
- func (slm ShardLockMaps) Get(key string) (interface{}, bool)
- func (slm ShardLockMaps) GetShard(key string) *SingleShardMap
- func (slm ShardLockMaps) Has(key string) bool
- func (slm ShardLockMaps) IsEmpty() bool
- func (slm ShardLockMaps) Items() map[string]interface{}
- func (slm ShardLockMaps) IterBuffered() <-chan Tuple
- func (slm ShardLockMaps) IterCb(fn IterCb)
- func (slm ShardLockMaps) Keys() []string
- func (slm ShardLockMaps) MSet(data map[string]interface{})
- func (slm ShardLockMaps) MarshalJSON() ([]byte, error)
- func (slm ShardLockMaps) Pop(key string) (v interface{}, exists bool)
- func (slm ShardLockMaps) Remove(key string)
- func (slm ShardLockMaps) RemoveCb(key string, cb RemoveCb) bool
- func (slm ShardLockMaps) Set(key string, value interface{})
- func (slm ShardLockMaps) SetNX(key string, value interface{}) bool
- func (slm ShardLockMaps) UnmarshalJSON(b []byte) (err error)
- type SingleShardMap
- type Tuple
- type Writer
Constants ¶
const ( Prime = 16777619 HashVal = 2166136261 )
Variables ¶
var ShardCount = 32
Functions ¶
Types ¶
type IDWorker ¶
type IDWorker struct {
// contains filtered or unexported fields
}
func NewIDWorker ¶
type IHash ¶ added in v1.2.2
func DefaultHash ¶ added in v1.2.2
func DefaultHash() IHash
type IterCb ¶ added in v1.2.0
type IterCb func(key string, v interface{})
IterCb Iterator callback,called for every key,value found in maps. RLock is held for all calls for a given shard therefore callback sess consistent view of a shard, but not across the shards
type RemoveCb ¶ added in v1.2.0
RemoveCb is a callback executed in a map.RemoveCb() call, while Lock is held If returns true, the element will be removed from the map
type ShardLockMaps ¶ added in v1.2.0
type ShardLockMaps struct {
// contains filtered or unexported fields
}
ShardLockMaps A "thread" safe map of type string:Anything. To avoid lock bottlenecks this map is dived to several (ShardCount) map shards.
func NewShardLockMaps ¶ added in v1.2.0
func NewShardLockMaps() ShardLockMaps
NewShardLockMaps Creates a new ShardLockMaps.
func NewWithCustomHash ¶ added in v1.2.2
func NewWithCustomHash(hash IHash) ShardLockMaps
func (ShardLockMaps) Clear ¶ added in v1.2.0
func (slm ShardLockMaps) Clear()
Clear removes all items from map.
func (ShardLockMaps) Count ¶ added in v1.2.0
func (slm ShardLockMaps) Count() int
Count returns the number of elements within the map.
func (ShardLockMaps) Get ¶ added in v1.2.0
func (slm ShardLockMaps) Get(key string) (interface{}, bool)
Get retrieves an element from map under given key.
func (ShardLockMaps) GetShard ¶ added in v1.2.0
func (slm ShardLockMaps) GetShard(key string) *SingleShardMap
GetShard returns shard under given key
func (ShardLockMaps) Has ¶ added in v1.2.0
func (slm ShardLockMaps) Has(key string) bool
Has Looks up an item under specified key
func (ShardLockMaps) IsEmpty ¶ added in v1.2.0
func (slm ShardLockMaps) IsEmpty() bool
IsEmpty checks if map is empty.
func (ShardLockMaps) Items ¶ added in v1.2.0
func (slm ShardLockMaps) Items() map[string]interface{}
Items returns all items as map[string]interface{}
func (ShardLockMaps) IterBuffered ¶ added in v1.2.0
func (slm ShardLockMaps) IterBuffered() <-chan Tuple
IterBuffered returns a buffered iterator which could be used in a for range loop.
func (ShardLockMaps) IterCb ¶ added in v1.2.0
func (slm ShardLockMaps) IterCb(fn IterCb)
IterCb Callback based iterator, cheapest way to read all elements in a map.
func (ShardLockMaps) Keys ¶ added in v1.2.0
func (slm ShardLockMaps) Keys() []string
Keys returns all keys as []string
func (ShardLockMaps) MSet ¶ added in v1.2.0
func (slm ShardLockMaps) MSet(data map[string]interface{})
MSet Sets the given value under the specified key.
func (ShardLockMaps) MarshalJSON ¶ added in v1.2.0
func (slm ShardLockMaps) MarshalJSON() ([]byte, error)
MarshalJSON Reviles ConcurrentMap "private" variables to json marshal.
func (ShardLockMaps) Pop ¶ added in v1.2.0
func (slm ShardLockMaps) Pop(key string) (v interface{}, exists bool)
Pop removes an element from the map and returns it
func (ShardLockMaps) Remove ¶ added in v1.2.0
func (slm ShardLockMaps) Remove(key string)
Remove removes an element from the map.
func (ShardLockMaps) RemoveCb ¶ added in v1.2.0
func (slm ShardLockMaps) RemoveCb(key string, cb RemoveCb) bool
RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map)
func (ShardLockMaps) Set ¶ added in v1.2.0
func (slm ShardLockMaps) Set(key string, value interface{})
Set Sets the given value under the specified key.
func (ShardLockMaps) SetNX ¶ added in v1.2.0
func (slm ShardLockMaps) SetNX(key string, value interface{}) bool
SetNX Sets the given value under the specified key if no value was associated with it.
func (ShardLockMaps) UnmarshalJSON ¶ added in v1.2.0
func (slm ShardLockMaps) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Reverse process of Marshal.
type SingleShardMap ¶ added in v1.2.0
SingleShardMap A "thread" safe string to anything map.
type Tuple ¶ added in v1.2.0
type Tuple struct { Key string Val interface{} }
Tuple Used by the IterBuffered functions to wrap two variables together over a channel,
type Writer ¶ added in v1.1.18
type Writer struct {
// contains filtered or unexported fields
}
func (*Writer) SetMaxSize ¶ added in v1.1.18
SetMaxSize 单个日志最大容量