Merge pull request #79 from alimy/pr-cache

optimize #78 change CacheIndex in conf.yaml to SimpleCacheIndex
pull/80/head
Michael Li 3 years ago committed by GitHub
commit 315060233b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,7 +16,7 @@ Features:
Develop: ["Base", "Option", "Sms", "AliOSS", "LoggerZinc"]
Slim: ["Base", "LocalOSS", "LoggerFile"]
Base: ["Zinc", "MySQL", "Redis", "Alipay",]
Option: ["CacheIndex"]
Option: ["SimpleCacheIndex"]
Sms: "SmsJuhe"
SmsJuhe:
Key:
@ -25,7 +25,7 @@ SmsJuhe:
Alipay:
AppID:
PrivateKey:
CacheIndex: # 缓存泡泡广场消息流
SimpleCacheIndex: # 缓存泡泡广场消息流
MaxIndexSize: 200 # 最大缓存条数
CheckTickDuration: 60 # 循环自检查每多少秒一次
ExpireTickDuration: 300 # 每多少秒后强制过期缓存

@ -15,7 +15,7 @@ var (
ServerSetting *ServerSettingS
AppSetting *AppSettingS
CacheIndexSetting *CacheIndexSettingS
SimpleCacheIndexSetting *SimpleCacheIndexSettingS
SmsJuheSetting *SmsJuheSettings
AlipaySetting *AlipaySettingS
ZincSetting *ZincSettingS
@ -43,7 +43,7 @@ func setupSetting(suite []string, noDefault bool) error {
objects := map[string]interface{}{
"App": &AppSetting,
"Server": &ServerSetting,
"CacheIndex": &CacheIndexSetting,
"SimpleCacheIndex": &SimpleCacheIndexSetting,
"Alipay": &AlipaySetting,
"SmsJuhe": &SmsJuheSetting,
"LoggerFile": &loggerFileSetting,

@ -46,7 +46,7 @@ type AppSettingS struct {
TronApiKeys []string
}
type CacheIndexSettingS struct {
type SimpleCacheIndexSettingS struct {
MaxIndexSize int
CheckTickDuration int
ExpireTickDuration int

@ -10,7 +10,7 @@ import (
)
func newSimpleCacheIndexServant(getIndexPosts func(offset, limit int) ([]*model.PostFormated, error)) *simpleCacheIndexServant {
s := conf.CacheIndexSetting
s := conf.SimpleCacheIndexSetting
cacheIndex := &simpleCacheIndexServant{
getIndexPosts: getIndexPosts,
maxIndexSize: s.MaxIndexSize,

@ -71,11 +71,11 @@ func NewDataService(engine *gorm.DB, zinc *zinc.ZincClient) core.DataService {
}
// initialize CacheIndex if needed
if !conf.CfgIf("CacheIndex") {
ds.useCacheIndex = false
} else {
if conf.CfgIf("SimpleCacheIndex") {
ds.useCacheIndex = true
ds.cacheIndex = newSimpleCacheIndexServant(ds.getIndexPosts)
} else {
ds.useCacheIndex = false
}
return ds

Loading…
Cancel
Save