mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 11:02:54 +00:00
feat: Add caching layer to carrier connector profile repository with 5-minute TTL
- Add CachedProfileStore wrapper around PostgresProfileStore with 5-minute TTL - Add defer close for underlying postgresRepo to ensure proper cleanup - Rename profileRepo variable to postgresRepo for clarity before wrapping - Add caching layer to reduce database load for profile lookups
This commit is contained in:
@@ -46,10 +46,14 @@ func main() {
|
||||
if dsn == "" {
|
||||
handler.Logger.Fatal().Msg("DATABASE_DSN is required (no in-memory fallback)")
|
||||
}
|
||||
profileRepo, err := repository.NewPostgresProfileStore(dsn)
|
||||
postgresRepo, err := repository.NewPostgresProfileStore(dsn)
|
||||
if err != nil {
|
||||
handler.Logger.Fatal().Err(err).Msg("Failed to connect to Postgres")
|
||||
}
|
||||
defer postgresRepo.Close()
|
||||
|
||||
// Wrap with cache (5 minute TTL)
|
||||
profileRepo := repository.NewCachedProfileStore(postgresRepo, 5*time.Minute)
|
||||
defer profileRepo.Close()
|
||||
|
||||
setupRoutes(router, client, profileRepo)
|
||||
|
||||
Reference in New Issue
Block a user