diff --git a/internal/dao/sakila/sakila.go b/internal/dao/sakila/sakila.go index 43dfdbec..0ad570ed 100644 --- a/internal/dao/sakila/sakila.go +++ b/internal/dao/sakila/sakila.go @@ -73,16 +73,23 @@ func NewDataService() (core.DataService, core.VersionInfo) { } // initialize core.CacheIndexService - if cfg.If("SimpleCacheIndex") { - // simpleCache use special post index service - ips = newSimpleIndexPostsService(_db, ths) - cis, v = cache.NewSimpleCacheIndexService(ips) - } else if cfg.If("BigCacheIndex") { - // TODO: make cache index post in different scence like friendship/followship/lightship - cis, v = cache.NewBigCacheIndexService(ips, ams) - } else { + cfg.On(cfg.Actions{ + "SimpleCacheIndex": func() { + // simpleCache use special post index service + ips = newSimpleIndexPostsService(_db, ths) + cis, v = cache.NewSimpleCacheIndexService(ips) + }, + "BigCacheIndex": func() { + // TODO: make cache index post in different scence like friendship/followship/lightship + cis, v = cache.NewBigCacheIndexService(ips, ams) + }, + "RedisCacheIndex": func() { + cis, v = cache.NewRedisCacheIndexService(ips, ams) + }, + }, func() { + // defualt no cache cis, v = cache.NewNoneCacheIndexService(ips) - } + }) logrus.Infof("use %s as cache index service by version: %s", v.Name(), v.Version()) ds := &dataSrv{