add redis cache to results

This commit is contained in:
timka committed 2025-12-17 18:38:54 +03:00
1 parent 7bf909652b
commit f5f6c7850c
4 files changed
+89 -17

No files matched your search

+11 -7
View File
@@ -11,18 +11,20 @@ import (
)
type Config struct {
GRPCPort int
GRPCEnableReflection bool
HTTPPort int
LogLevel string
DBHost string
DBPort int
GRPCPort int
GRPCEnableReflection bool
HTTPPort int
LogLevel string
DBHost string
DBPort int
DBUser string
DBPassword string
DBName string
RedisAddr string
UserServiceAddr string
SubmissionServiceAddr string
TaskServiceAddr string
CacheEnabled bool
}
func Load() (*Config, error) {
@@ -38,9 +40,11 @@ func Load() (*Config, error) {
DBUser: getEnv("POSTGRES_USERNAME", "postgres"),
DBPassword: getEnv("POSTGRES_PASSWORD", "postgres"),
DBName: getEnv("POSTGRES_DATABASE", "postgres"),
RedisAddr: getEnv("REDIS_ADDR", "localhost:6379"),
UserServiceAddr: getEnv("USER_GRPC_ADDR", "localhost:50051"),
SubmissionServiceAddr: getEnv("SUBMISSION_GRPC_ADDR", "localhost:50055"),
TaskServiceAddr: getEnv("TASK_GRPC_ADDR", "localhost:50056"),
CacheEnabled: mustGetBool("CACHE_ENABLED", false),
}, nil
}
@@ -77,4 +81,4 @@ func (c Config) BuildPostgresConnStr() string {
func (c Config) BuildPostgresDSN() string {
return fmt.Sprintf("postgresql://%s:%s@%s/%s?sslmode=disable",
c.DBUser, c.DBPassword, net.JoinHostPort(c.DBHost, strconv.Itoa(c.DBPort)), c.DBName)
}
}