From 1cfae9f67a9ff7240d77ece8a2e0c54326e35c66 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 8 Jul 2026 20:37:07 +0200 Subject: removed mutex from redisDB struct and moved Execute method to shards.go file --- shards.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'shards.go') diff --git a/shards.go b/shards.go index bd19751..cba4dd4 100644 --- a/shards.go +++ b/shards.go @@ -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) +} -- cgit v1.2.3