You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
628 B
37 lines
628 B
package service |
|
|
|
import ( |
|
"context" |
|
"flag" |
|
"path/filepath" |
|
"time" |
|
|
|
"go-common/app/interface/main/creative/conf" |
|
"go-common/library/cache/redis" |
|
|
|
. "github.com/smartystreets/goconvey/convey" |
|
) |
|
|
|
var ( |
|
pvr *Public |
|
) |
|
|
|
func CleanCache() { |
|
c := context.TODO() |
|
pool := redis.NewPool(conf.Conf.Redis.Antispam.Config) |
|
pool.Get(c).Do("FLUSHDB") |
|
} |
|
|
|
func init() { |
|
dir, _ := filepath.Abs("../cmd/creative.toml") |
|
flag.Set("conf", dir) |
|
conf.Init() |
|
pvr = New(conf.Conf, NewRPCDaos(conf.Conf)) |
|
time.Sleep(time.Second) |
|
} |
|
func WithService(f func(p *Public)) func() { |
|
return func() { |
|
Reset(func() { CleanCache() }) |
|
f(pvr) |
|
} |
|
}
|
|
|