Merge pull request #81 from alimy/pr-cache

optimize #78 support disable expire cache index if needed
pull/82/head
Michael Li 3 years ago committed by GitHub
commit 91c2d42111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,7 +28,7 @@ Alipay:
SimpleCacheIndex: # 缓存泡泡广场消息流
MaxIndexSize: 200 # 最大缓存条数
CheckTickDuration: 60 # 循环自检查每多少秒一次
ExpireTickDuration: 300 # 每多少秒后强制过期缓存
ExpireTickDuration: 300 # 每多少秒后强制过期缓存, 设置为0禁止强制使缓存过期
LoggerFile: # 使用File写日志
SavePath: data/paopao-ce/logs
FileName: app

@ -17,7 +17,14 @@ func newSimpleCacheIndexServant(getIndexPosts func(offset, limit int) ([]*model.
indexPosts: make([]*model.PostFormated, 0),
indexActionCh: make(chan core.IndexActionT, 100), // optimize: size need configure by custom
checkTick: time.NewTicker(time.Duration(s.CheckTickDuration) * time.Second), // check whether need update index every 1 minute
expireIndexTick: time.NewTicker(time.Duration(s.ExpireTickDuration) * time.Second), // force expire index every 5 minute
expireIndexTick: time.NewTicker(time.Second),
}
// force expire index every ExpireTickDuration second
if s.ExpireTickDuration != 0 {
cacheIndex.expireIndexTick.Reset(time.Duration(s.CheckTickDuration) * time.Second)
} else {
cacheIndex.expireIndexTick.Stop()
}
// start index posts

Loading…
Cancel
Save