go-redis
go-redis copied to clipboard
Add support for update cmd in the hooks
In multi tenant SasS system, I want to update cmd before process.
type RedisHooks struct {}
func (h *RedisHooks) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) {
tenantID, ok := ctx.Value(TenantKey{}).(string)
if !ok {
return ctx, nil
}
// Update cmd there.
// For example: when use redis.set, could set newKey = tenantID + oldKey
return ctx, nil
}