diff --git a/cache/articlecache.go b/cache/articlecache.go index c4b36225..6010b6c3 100644 --- a/cache/articlecache.go +++ b/cache/articlecache.go @@ -19,6 +19,7 @@ package cache import ( "os" + "time" "github.com/88250/gulu" "github.com/88250/pipe/model" @@ -30,7 +31,7 @@ var logger = gulu.Log.NewLogger(os.Stdout) // Article cache. var Article = &articleCache{ - idHolder: gcache.New(1024 * 10).LRU().Build(), + idHolder: gcache.New(1024 * 10).LRU().Expiration(30 * time.Minute).Build(), } type articleCache struct { diff --git a/cache/commentcache.go b/cache/commentcache.go index c7eb045e..8e38f9e9 100644 --- a/cache/commentcache.go +++ b/cache/commentcache.go @@ -17,13 +17,15 @@ package cache import ( + "time" + "github.com/88250/pipe/model" "github.com/bluele/gcache" ) // Comment service. var Comment = &commentCache{ - idHolder: gcache.New(1024 * 10 * 10).LRU().Build(), + idHolder: gcache.New(1024 * 10 * 10).LRU().Expiration(30 * time.Minute).Build(), } type commentCache struct { diff --git a/cache/settingcache.go b/cache/settingcache.go index e3aaf93a..bdc30f3b 100644 --- a/cache/settingcache.go +++ b/cache/settingcache.go @@ -18,6 +18,7 @@ package cache import ( "fmt" + "time" "github.com/88250/pipe/model" "github.com/bluele/gcache" @@ -25,7 +26,7 @@ import ( // Setting cache. var Setting = &settingCache{ - categoryNameHolder: gcache.New(1024 * 10).LRU().Build(), + categoryNameHolder: gcache.New(1024 * 10).LRU().Expiration(30 * time.Minute).Build(), } type settingCache struct { diff --git a/cache/usercache.go b/cache/usercache.go index cf194dfc..9d9d841c 100644 --- a/cache/usercache.go +++ b/cache/usercache.go @@ -17,13 +17,15 @@ package cache import ( + "time" + "github.com/88250/pipe/model" "github.com/bluele/gcache" ) // User cache. var User = &userCache{ - idHolder: gcache.New(1024 * 10).LRU().Build(), + idHolder: gcache.New(1024 * 10).LRU().Expiration(30 * time.Minute).Build(), } type userCache struct { diff --git a/util/markdowns.go b/util/markdowns.go index 1b612538..6cd3de51 100644 --- a/util/markdowns.go +++ b/util/markdowns.go @@ -20,16 +20,17 @@ import ( "crypto/md5" "regexp" "strings" + "time" "unicode" "unicode/utf8" - "github.com/PuerkitoBio/goquery" "github.com/88250/lute" + "github.com/PuerkitoBio/goquery" "github.com/bluele/gcache" "github.com/microcosm-cc/bluemonday" ) -var markdownCache = gcache.New(1024).LRU().Build() +var markdownCache = gcache.New(1024).LRU().Expiration(30 * time.Minute).Build() // MarkdownResult represents markdown result. type MarkdownResult struct {