Skip to content

Commit

Permalink
🎨 设置数据缓存时间为 30m Fix #18
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Feb 15, 2020
1 parent e27dd19 commit 4b44a7a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cache/articlecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cache

import (
"os"
"time"

"github.com/88250/gulu"
"github.com/88250/pipe/model"
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion cache/commentcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion cache/settingcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ package cache

import (
"fmt"
"time"

"github.com/88250/pipe/model"
"github.com/bluele/gcache"
)

// 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 {
Expand Down
4 changes: 3 additions & 1 deletion cache/usercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions util/markdowns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4b44a7a

Please sign in to comment.