aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting/setting.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r--modules/setting/setting.go32
1 files changed, 22 insertions, 10 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 9787e09280..6c89381f3b 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -325,11 +325,6 @@ var (
// Time settings
TimeFormat string
- // Cache settings
- CacheAdapter string
- CacheInterval int
- CacheConn string
-
// Session settings
SessionConfig session.Options
CSRFCookieName = "_csrf"
@@ -1295,16 +1290,33 @@ func NewXORMLogService(disableConsole bool) {
}
}
+// Cache represents cache settings
+type Cache struct {
+ Adapter string
+ Interval int
+ Conn string
+ TTL time.Duration
+}
+
+var (
+ // CacheService the global cache
+ CacheService *Cache
+)
+
func newCacheService() {
- CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"})
- switch CacheAdapter {
+ sec := Cfg.Section("cache")
+ CacheService = &Cache{
+ Adapter: sec.Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"}),
+ }
+ switch CacheService.Adapter {
case "memory":
- CacheInterval = Cfg.Section("cache").Key("INTERVAL").MustInt(60)
+ CacheService.Interval = sec.Key("INTERVAL").MustInt(60)
case "redis", "memcache":
- CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ")
+ CacheService.Conn = strings.Trim(sec.Key("HOST").String(), "\" ")
default:
- log.Fatal(4, "Unknown cache adapter: %s", CacheAdapter)
+ log.Fatal(4, "Unknown cache adapter: %s", CacheService.Adapter)
}
+ CacheService.TTL = sec.Key("ITEM_TTL").MustDuration(16 * time.Hour)
log.Info("Cache Service Enabled")
}