diff options
| author | alex <[email protected]> | 2026-07-08 20:37:07 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-08 20:37:07 +0200 |
| commit | 1cfae9f67a9ff7240d77ece8a2e0c54326e35c66 (patch) | |
| tree | 128a96bf9fec88aa554b6b5034b2697f7914b2d1 /shards.go | |
| parent | 880d3ae49f178e61be809fb5d2c68d5f63ea700b (diff) | |
| download | redis-clone-1cfae9f67a9ff7240d77ece8a2e0c54326e35c66.tar.xz redis-clone-1cfae9f67a9ff7240d77ece8a2e0c54326e35c66.zip | |
removed mutex from redisDB struct and moved Execute method to shards.go file
Diffstat (limited to 'shards.go')
| -rw-r--r-- | shards.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -16,4 +16,11 @@ func (db *RedisDB) getShard(key string)*Shard{ val := hash.Sum64() return db.shards[val%16] -}
\ No newline at end of file +} + +func (db *RedisDB) Execute(key string, fn func(*Shard) interface{}) interface{} { + shard := db.getShard(key) + shard.mu.Lock() + defer shard.mu.Unlock() + return fn(shard) +} |
