mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 06:04:40 +01:00
add cache
This commit is contained in:
parent
e4053f5e98
commit
c7e0d3a499
3 changed files with 23 additions and 0 deletions
|
@ -60,6 +60,10 @@ FROM =
|
||||||
USER =
|
USER =
|
||||||
PASSWD =
|
PASSWD =
|
||||||
|
|
||||||
|
[cache]
|
||||||
|
ADAPTER = memory
|
||||||
|
CONFIG =
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
; Either "console", "file", "conn" or "smtp", default is "console"
|
; Either "console", "file", "conn" or "smtp", default is "console"
|
||||||
MODE = console
|
MODE = console
|
||||||
|
|
|
@ -15,6 +15,8 @@ import (
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
"github.com/Unknwon/goconfig"
|
"github.com/Unknwon/goconfig"
|
||||||
|
|
||||||
|
"github.com/gogits/cache"
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,6 +39,10 @@ var (
|
||||||
|
|
||||||
Cfg *goconfig.ConfigFile
|
Cfg *goconfig.ConfigFile
|
||||||
MailService *Mailer
|
MailService *Mailer
|
||||||
|
|
||||||
|
Cache cache.Cache
|
||||||
|
CacheAdapter string
|
||||||
|
CacheConfig string
|
||||||
)
|
)
|
||||||
|
|
||||||
var Service struct {
|
var Service struct {
|
||||||
|
@ -182,6 +188,16 @@ func NewConfigContext() {
|
||||||
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
|
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
|
||||||
RunUser = Cfg.MustValue("", "RUN_USER")
|
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.
|
// Determine and create root git reposiroty path.
|
||||||
RepoRootPath = Cfg.MustValue("repository", "ROOT")
|
RepoRootPath = Cfg.MustValue("repository", "ROOT")
|
||||||
if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil {
|
if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil {
|
||||||
|
|
|
@ -12,6 +12,8 @@ import (
|
||||||
"github.com/codegangsta/martini"
|
"github.com/codegangsta/martini"
|
||||||
"github.com/martini-contrib/sessions"
|
"github.com/martini-contrib/sessions"
|
||||||
|
|
||||||
|
"github.com/gogits/cache"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
|
@ -25,6 +27,7 @@ type Context struct {
|
||||||
Req *http.Request
|
Req *http.Request
|
||||||
Res http.ResponseWriter
|
Res http.ResponseWriter
|
||||||
Session sessions.Session
|
Session sessions.Session
|
||||||
|
Cache cache.Cache
|
||||||
User *models.User
|
User *models.User
|
||||||
IsSigned bool
|
IsSigned bool
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue