diff options
| author | alex <[email protected]> | 2026-07-08 20:35:41 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-08 20:35:41 +0200 |
| commit | 880d3ae49f178e61be809fb5d2c68d5f63ea700b (patch) | |
| tree | 3919f0d42c7cd5f2fe82ea5399008c62db58801f | |
| parent | 513e5e7961ecc9fe8155811d6cbb6a6c77e0638d (diff) | |
| download | redis-clone-880d3ae49f178e61be809fb5d2c68d5f63ea700b.tar.xz redis-clone-880d3ae49f178e61be809fb5d2c68d5f63ea700b.zip | |
gave shards ids
| -rw-r--r-- | handlers.go | 3 | ||||
| -rw-r--r-- | main.go | 1 | ||||
| -rw-r--r-- | shards.go | 1 |
3 files changed, 2 insertions, 3 deletions
diff --git a/handlers.go b/handlers.go index aefea85..1a04db9 100644 --- a/handlers.go +++ b/handlers.go @@ -59,9 +59,6 @@ func handleExists(conn net.Conn, args []string) { } func handleSet(conn net.Conn, args []string) { - db.mu.Lock() - defer db.mu.Unlock() - if len(args) != 3 { err := errors.New("wrong number of arguments for 'SET'") conn.Write(serializeRESP(err)) @@ -47,6 +47,7 @@ func main() { for i := 0; i < numShards; i++ { shards[i] = &Shard{ data: make(map[string]Item), + id: i, } } db = RedisDB{shards: shards} @@ -6,6 +6,7 @@ import ( ) type Shard struct{ mu sync.Mutex + id int data map[string]Item } |
