From 9dea5b6ddeae5bdfd695a6e7cda33acaae00b727 Mon Sep 17 00:00:00 2001 From: garrettladley Date: Tue, 11 Jun 2024 19:19:37 -0400 Subject: [PATCH] constant for cache ttl --- backend/constants/db.go | 1 + backend/database/db.go | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/constants/db.go b/backend/constants/db.go index eb6d046e..8fdd94d9 100644 --- a/backend/constants/db.go +++ b/backend/constants/db.go @@ -6,4 +6,5 @@ const ( MAX_IDLE_CONNECTIONS int = 10 MAX_OPEN_CONNECTIONS int = 100 DB_TIMEOUT time.Duration = 200 * time.Millisecond + DB_CACHE_TTL time.Duration = 60 * time.Second ) diff --git a/backend/database/db.go b/backend/database/db.go index 183eae10..e09aeb8a 100644 --- a/backend/database/db.go +++ b/backend/database/db.go @@ -2,7 +2,6 @@ package database import ( "errors" - "time" "github.com/GenerateNU/sac/backend/config" "github.com/GenerateNU/sac/backend/constants" @@ -20,7 +19,7 @@ func ConfigureDB(settings config.Settings) (*gorm.DB, error) { } cache := cache.NewGormCache("db_cache", cache.NewRedisClient(settings.DBCache), cache.CacheConfig{ - TTL: 60 * time.Second, + TTL: constants.DB_CACHE_TTL, Prefix: "cache:", })