Redis cache

This commit is contained in:
2025-03-29 02:24:15 +08:00
parent f3f9ebb5af
commit 1651328a74
26 changed files with 786 additions and 636 deletions

View File

@@ -7,6 +7,7 @@ import (
"syscall"
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
"git.solsynth.dev/hypernet/nexus/pkg/internal/cache"
"git.solsynth.dev/hypernet/nexus/pkg/internal/database"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
@@ -71,6 +72,14 @@ func main() {
log.Info().Msg("Connected to MQ (nats)!")
}
// Connect to cache (redis)
log.Info().Msg("Connecting to cache (redis)...")
if err := cache.ConnectRedis(viper.GetString("cache.addr"), viper.GetString("cache.password"), 0); err != nil {
log.Error().Err(err).Msg("An error occurred when connecting to cache (redis). Cache related features will be disabled.")
} else {
log.Info().Msg("Connected to cache (redis)!")
}
// Connect to database
log.Info().Msg("Connecting to database...")
if db, err := database.Connect(viper.GetString("database.dsn")); err != nil {