55
//
56
// The hash function to use for sharding
57
>
func NewShardedConcurrentTxMap(initialCap int, hashfn HashFunc) ConcurrentTxMap {
concurrent_tx_map.go
58
>
cmap := new(ShardedConcurrentTxMap)
59
>
cmap.hashfn = hashfn
60
>
cmap.initialCap = max(nShards, initialCap/nShards)
61
>
return cmap
62
>
}
63
64
// Get returns the value corresponding to the key, if it exist
66
>
shard := cmap.getShard(key)
67
>
var ok bool
68
>
var value any
69
>
shard.RLock()
70
>
if shard.items != nil {
71
>
value, ok = shard.items[key]
72
>
}
73
>
shard.RUnlock()
74
>
return value, ok
75
}
76