diff options
Diffstat (limited to 'shards.go')
| -rw-r--r-- | shards.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/shards.go b/shards.go new file mode 100644 index 0000000..55ab976 --- /dev/null +++ b/shards.go @@ -0,0 +1,18 @@ +package main + +import ( + "hash/fnv" + "sync" +) +type Shard struct{ + mu sync.Mutex + data map[string]Item +} + +func (db *RedisDB) getShard(key string)*Shard{ + hash := fnv.New64a() + hash.Write([]byte(key)) + val := hash.Sum64() + + return db.shards[val%16] +}
\ No newline at end of file |
