lab2 fix
This commit is contained in:
+2
-18
@@ -70,18 +70,10 @@ func run(cfg config.Config, log *slog.Logger) error {
|
||||
pingers := []health.Pinger{store}
|
||||
|
||||
if cfg.Redis.Enabled {
|
||||
sessionRepo = storageredis.NewSessionRepository(
|
||||
store.Sessions(),
|
||||
redisCache,
|
||||
cfg.Cache.SessionTTL,
|
||||
log,
|
||||
)
|
||||
|
||||
if cfg.Cache.Enabled {
|
||||
distributed, err := cache.NewDistributed(redisCache, cache.DistributedConfig{
|
||||
LockTTL: cfg.Cache.LockTTL,
|
||||
WaitTimeout: cfg.Cache.LockWaitTimeout,
|
||||
TimeoutPolicy: timeoutPolicy(cfg.Cache.LockTimeoutPolicy),
|
||||
LockTTL: cfg.Cache.LockTTL,
|
||||
WaitTimeout: cfg.Cache.LockWaitTimeout,
|
||||
}, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("build distributed cache: %w", err)
|
||||
@@ -180,11 +172,3 @@ func connectRedis(cfg config.Redis) (cache.LockStore, error) {
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func timeoutPolicy(value string) cache.TimeoutPolicy {
|
||||
if value == "load" {
|
||||
return cache.TimeoutLoad
|
||||
}
|
||||
|
||||
return cache.TimeoutError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user