mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-02 16:35:19 +02:00
Split setting.go as multiple files (#6014)
* split setting.go as multiple files * fix comments
This commit is contained in:
parent
9e8cc3b18d
commit
820e28c904
7 changed files with 509 additions and 442 deletions
43
modules/setting/cache.go
Normal file
43
modules/setting/cache.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package setting
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// 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() {
|
||||
sec := Cfg.Section("cache")
|
||||
CacheService = &Cache{
|
||||
Adapter: sec.Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"}),
|
||||
}
|
||||
switch CacheService.Adapter {
|
||||
case "memory":
|
||||
CacheService.Interval = sec.Key("INTERVAL").MustInt(60)
|
||||
case "redis", "memcache":
|
||||
CacheService.Conn = strings.Trim(sec.Key("HOST").String(), "\" ")
|
||||
default:
|
||||
log.Fatal(4, "Unknown cache adapter: %s", CacheService.Adapter)
|
||||
}
|
||||
CacheService.TTL = sec.Key("ITEM_TTL").MustDuration(16 * time.Hour)
|
||||
|
||||
log.Info("Cache Service Enabled")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue