func (m CMap) Add(key string, value int64) {
	shard := m.GetShard(key)
	shard.Lock()
	shard.items[key] = value
	shard.Unlock()
}
Sets the given value under the specified key.
package uploader
import (
	"context"
	"sync"
	"sync/atomic"
	"time"
)
var shardCount = 1024
type CMap []*CMapShard
type CMapShard struct {
	sync.RWMutex  
	items        map[string]int64
}
func NewCMap() CMap {
	m := make(CMap, shardCount)
	for i := 0; i < shardCount; i++ {
		m[i] = &CMapShard{items: make(map[string]int64)}
	}
	return m
}
func fnv32(key string) uint32 {
	hash := uint32(2166136261)
	const prime32 = uint32(16777619)
	for i := 0; i < len(key); i++ {
		hash *= prime32
		hash ^= uint32(key[i])
	}
	return hash
}
func (m CMap) Count() int {
	count := 0
	for i := 0; i < shardCount; i++ {
		shard := m[i]
		shard.RLock()
		count += len(shard.items)
		shard.RUnlock()
	}
	return count
}
func (m CMap) Clear() int {
	count := 0
	for i := 0; i < shardCount; i++ {
		shard := m[i]
		shard.Lock()
		shard.items = make(map[string]int64)
		shard.Unlock()
	}
	return count
}
func (m CMap) GetShard(key string) *CMapShard {
	return m[uint(fnv32(key))%uint(shardCount)]
}
func (m CMap) Exists(key string) bool {
	shard := m.GetShard(key)
	shard.RLock()
	_, ok := shard.items[key]
	shard.RUnlock()
	return ok
}