summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorFuXiaoHei <fuxiaohei@hexiaz.com>2014-03-21 23:28:44 +0800
committerFuXiaoHei <fuxiaohei@hexiaz.com>2014-03-21 23:28:44 +0800
commit9218f76c8e4a6fafbe6bed1d61eb66ba73bf70f2 (patch)
tree881531e41b0a51a853845740e6728ddb4e5d5277 /modules
parent011134e0aff5d16501b60a6feaaa8c2ccf0d269d (diff)
parentd40499e7fa3d62655431f160b6909d9751dabe11 (diff)
downloadgitea-9218f76c8e4a6fafbe6bed1d61eb66ba73bf70f2.tar.gz
gitea-9218f76c8e4a6fafbe6bed1d61eb66ba73bf70f2.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'modules')
-rw-r--r--modules/base/conf.go35
1 files changed, 25 insertions, 10 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go
index 3962972cda..2c3ecd72d8 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -133,6 +133,30 @@ func newLogService() {
log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
}
+func newCacheService() {
+ CacheAdapter = Cfg.MustValue("cache", "ADAPTER", "memory")
+
+ switch CacheAdapter {
+ case "memory":
+ CacheConfig = fmt.Sprintf(`{"interval":%d}`, Cfg.MustInt("cache", "INTERVAL", 60))
+ case "redis", "memcache":
+ CacheConfig = fmt.Sprintf(`{"conn":"%s"}`, Cfg.MustValue("cache", "HOST"))
+ default:
+ fmt.Printf("Unknown cache adapter: %s\n", CacheAdapter)
+ os.Exit(2)
+ }
+
+ var err error
+ Cache, err = cache.NewCache(CacheAdapter, CacheConfig)
+ if err != nil {
+ fmt.Printf("Init cache system failed, adapter: %s, config: %s, %v\n",
+ CacheAdapter, CacheConfig, err)
+ os.Exit(2)
+ }
+
+ log.Info("Cache Service Enabled")
+}
+
func newMailService() {
// Check mailer setting.
if Cfg.MustBool("mailer", "ENABLED") {
@@ -188,16 +212,6 @@ func NewConfigContext() {
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
RunUser = Cfg.MustValue("", "RUN_USER")
- CacheAdapter = Cfg.MustValue("cache", "ADAPTER")
- CacheConfig = Cfg.MustValue("cache", "CONFIG")
-
- Cache, err = cache.NewCache(CacheAdapter, CacheConfig)
- if err != nil {
- fmt.Printf("Init cache system failed, adapter: %s, config: %s, %v\n",
- CacheAdapter, CacheConfig, err)
- os.Exit(2)
- }
-
// Determine and create root git reposiroty path.
RepoRootPath = Cfg.MustValue("repository", "ROOT")
if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil {
@@ -209,6 +223,7 @@ func NewConfigContext() {
func NewServices() {
newService()
newLogService()
+ newCacheService()
newMailService()
newRegisterMailService()
}