From 513e5e7961ecc9fe8155811d6cbb6a6c77e0638d Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 8 Jul 2026 20:30:16 +0200 Subject: refactored EXISTS,SET,GET to support multiple shards --- shards.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 shards.go (limited to 'shards.go') 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 -- cgit v1.2.3