apply new async cache to Monitor
This commit is contained in:
parent
2142095033
commit
abeaefa0d8
|
@ -121,6 +121,7 @@ object Env {
|
|||
def security = lila.security.Env.current
|
||||
def hub = lila.hub.Env.current
|
||||
def socket = lila.socket.Env.current
|
||||
def memo = lila.memo.Env.current
|
||||
def message = lila.message.Env.current
|
||||
def i18n = lila.i18n.Env.current
|
||||
def game = lila.game.Env.current
|
||||
|
|
|
@ -13,7 +13,7 @@ object Monitor extends LilaController {
|
|||
private object path {
|
||||
val coachPageView = "servers.lichess.statsite.counts.main.counter.coach.page_view.profile"
|
||||
}
|
||||
private val coachPageViewCache = lila.memo.AsyncCache[lila.user.User.ID, Result](
|
||||
private val coachPageViewCache = Env.memo.asyncCache[lila.user.User.ID, Result](
|
||||
name = "monitor.coachPageView",
|
||||
f = userId =>
|
||||
Env.coach.api byId lila.coach.Coach.Id(userId) flatMap {
|
||||
|
@ -33,10 +33,9 @@ object Monitor extends LilaController {
|
|||
}
|
||||
}
|
||||
},
|
||||
timeToLive = 10 seconds
|
||||
)
|
||||
expireAfter = _.ExpireAfterWrite(10 minute))
|
||||
|
||||
def coachPageView = Secure(_.Coach) { ctx => me =>
|
||||
coachPageViewCache(me.id)
|
||||
coachPageViewCache get me.id
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package controllers
|
|||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import lila.memo.AsyncCache2Single
|
||||
import io.prismic.Fragment.DocumentLink
|
||||
import io.prismic.{ Api => PrismicApi, _ }
|
||||
import lila.app._
|
||||
import lila.memo.AsyncCache2Single
|
||||
|
||||
object Prismic {
|
||||
|
||||
|
@ -17,10 +17,10 @@ object Prismic {
|
|||
case _ => logger info message
|
||||
}
|
||||
|
||||
private val prismicApiCache = AsyncCache2Single[PrismicApi](
|
||||
private val prismicApiCache = Env.memo.asyncCacheSingle[PrismicApi](
|
||||
name = "prismic.fetchPrismicApi",
|
||||
f = PrismicApi.get(Env.api.PrismicApiUrl, logger = prismicLogger),
|
||||
expireAfter = AsyncCache2Single.ExpireAfterWrite(1 minute))(Env.current.system)
|
||||
expireAfter = _.ExpireAfterWrite(1 minute))
|
||||
|
||||
def prismicApi = prismicApiCache.get
|
||||
|
||||
|
|
Loading…
Reference in a new issue