mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-21 03:28:46 +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 == "" {
|
if dsn == "" {
|
||||||
handler.Logger.Fatal().Msg("DATABASE_DSN is required (no in-memory fallback)")
|
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 {
|
if err != nil {
|
||||||
handler.Logger.Fatal().Err(err).Msg("Failed to connect to Postgres")
|
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()
|
defer profileRepo.Close()
|
||||||
|
|
||||||
setupRoutes(router, client, profileRepo)
|
setupRoutes(router, client, profileRepo)
|
||||||
|
|||||||
Reference in New Issue
Block a user