MCPcopy Index your code
hub / github.com/TruthHun/BookStack / UpdateAdsCache

Function UpdateAdsCache

models/ads.go:223–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

221}
222
223func UpdateAdsCache() {
224 var (
225 ads []AdsCont
226 cache sync.Map
227 data = make(map[int][]AdsCont)
228 )
229 now := time.Now().Unix()
230 orm.NewOrm().QueryTable(&AdsCont{}).Filter("status", 1).Filter("start__lt", now).Filter("end__gt", now).All(&ads)
231 for _, item := range ads {
232 data[item.Pid] = append(data[item.Pid], item)
233 }
234 if beego.AppConfig.String("runmode") == "dev" {
235 beego.Info(" =============== update ads cache =============== ")
236 }
237 for pid, arr := range data {
238 cache.Store(pid, arr)
239 }
240 adsCache = cache
241}
242
243func (m *AdsCont) GetPositions() []AdsPosition {
244 var positions []AdsPosition

Callers 4

UpdateAdsMethod · 0.92
DelAdsMethod · 0.92
AdsMethod · 0.92
initAdsCacheFunction · 0.85

Calls 2

appendFunction · 0.50
AllMethod · 0.45

Tested by

no test coverage detected