Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentMap ¶
type ConcurrentMap struct {
// contains filtered or unexported fields
}
ConcurrentMap 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.
func CreateConcurrentMap ¶
func CreateConcurrentMap(numOfPartitions int) *ConcurrentMap
CreateConcurrentMap is to create a ConcurrentMap with the setting number of the partitions
func (*ConcurrentMap) Del ¶
func (m *ConcurrentMap) Del(key Partitionable)
Del is to delete the entries by the key
func (*ConcurrentMap) Get ¶
func (m *ConcurrentMap) Get(key Partitionable) (interface{}, bool)
Get is to get the value by the key
func (*ConcurrentMap) Set ¶
func (m *ConcurrentMap) Set(key Partitionable, v interface{})
Set is to store the KV entry to the map
type ConcurrentMapBenchmarkAdapter ¶
type ConcurrentMapBenchmarkAdapter struct {
// contains filtered or unexported fields
}
func CreateConcurrentMapBenchmarkAdapter ¶
func CreateConcurrentMapBenchmarkAdapter(numOfPartitions int) *ConcurrentMapBenchmarkAdapter
func (*ConcurrentMapBenchmarkAdapter) Del ¶
func (m *ConcurrentMapBenchmarkAdapter) Del(key interface{})
func (*ConcurrentMapBenchmarkAdapter) Get ¶
func (m *ConcurrentMapBenchmarkAdapter) Get(key interface{}) (interface{}, bool)
func (*ConcurrentMapBenchmarkAdapter) Set ¶
func (m *ConcurrentMapBenchmarkAdapter) Set(key interface{}, value interface{})
type Int64Key ¶
type Int64Key struct {
// contains filtered or unexported fields
}
func (*Int64Key) PartitionKey ¶
PartitionID is created by string's hash
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.
type RWLockMap ¶
type RWLockMap struct {
// contains filtered or unexported fields
}
func CreateRWLockMap ¶
func CreateRWLockMap() *RWLockMap
type StringKey ¶
type StringKey struct {
// contains filtered or unexported fields
}
StringKey is for the string type key
func (*StringKey) PartitionKey ¶
PartitionID is created by string's hash
type SyncMapBenchmarkAdapter ¶
type SyncMapBenchmarkAdapter struct {
// contains filtered or unexported fields
}
func CreateSyncMapBenchmarkAdapter ¶
func CreateSyncMapBenchmarkAdapter() *SyncMapBenchmarkAdapter
func (*SyncMapBenchmarkAdapter) Del ¶
func (m *SyncMapBenchmarkAdapter) Del(key interface{})
func (*SyncMapBenchmarkAdapter) Get ¶
func (m *SyncMapBenchmarkAdapter) Get(key interface{}) (interface{}, bool)
func (*SyncMapBenchmarkAdapter) Set ¶
func (m *SyncMapBenchmarkAdapter) Set(key interface{}, val interface{})