diff options
Diffstat (limited to 'redisDB.go')
| -rw-r--r-- | redisDB.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -9,13 +9,21 @@ type Item struct { Value any ExpiresAt *time.Time } + type RedisDB struct { mu sync.Mutex - data map[string]Item + shards []*Shard } type SimpleString string +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) +} + func serializeRESP(v any) []byte { switch val := v.(type) { case string: |
