diff options
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) +} |
