(key []byte)
| 213 | } |
| 214 | |
| 215 | func (g *GroupCache) Get(key []byte) ([]byte, error) { |
| 216 | hashVal := xxhash.Sum64(key) |
| 217 | shardNum := hashVal & segmentAndOpVal |
| 218 | |
| 219 | g.locks[shardNum].Lock() |
| 220 | v, ok := g.shards[shardNum].Get(string(key)) |
| 221 | g.locks[shardNum].Unlock() |
| 222 | |
| 223 | if ok { |
| 224 | return v.([]byte), nil |
| 225 | } |
| 226 | return nil, errKeyNotFound |
| 227 | } |
| 228 | |
| 229 | func (g *GroupCache) Set(key, value []byte) error { |
| 230 | hashVal := xxhash.Sum64(key) |