Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func I64Key ¶
func I64Key(key int64) *concurrent_map.Int64Key
I64Key is to convert a int64 to Int64Key
func StrKey ¶
func StrKey(key string) *concurrent_map.StringKey
StrKey is to convert a string to StringKey
Types ¶
type CMap ¶
type CMap struct {
// contains filtered or unexported fields
}
CMap is a thread safe map collection with better performance. The backend map entries are separated into the different partitions. Threads can access the different partitions safely without lock.
inwrap for concurrent_map.ConcurrentMap
func New ¶
New is to create a ConcurrentMap with the setting number of the partitions
inwrap for concurrent_map.CreateConcurrentMap
func (*CMap) Del ¶
func (m *CMap) Del(key Partitionable)
Del is to delete the entries by the key
inwrap for concurrent_map.CreateConcurrentMap
func (*CMap) Get ¶
func (m *CMap) Get(key Partitionable) (interface{}, bool)
Get is to get the value by the key
inwrap for concurrent_map.CreateConcurrentMap
func (*CMap) Set ¶
func (m *CMap) Set(key Partitionable, v interface{})
Set is to store the KV entry to the map
inwrap for concurrent_map.CreateConcurrentMap
type Partitionable ¶
type Partitionable interface { // Value is raw value of the key Value() interface{} // PartitionKey is used for getting the partition to store the entry with the key. // E.g. the key's hash could be used as its PartitionKey // The partition for the key is partitions[(PartitionKey % m.numOfBlockets)] // // 1 Why not provide the default hash function for partition? // Ans: As you known, the partition solution would impact the performance significantly. // The proper partition solution balances the access to the different partitions and // avoid of the hot partition. The access mode highly relates to your business. // So, the better partition solution would just be designed according to your business. PartitionKey() int64 }
Partitionable is the interface which should be implemented by key type. It is to define how to partition the entries.
inwrap for concurrent_map.Partitionable