the daily puzzle cache was instanciated at every homepage hit!
This commit is contained in:
parent
334b72de71
commit
ee7fb75db3
|
@ -53,9 +53,7 @@ final class Env(
|
|||
asyncCache = Env.memo.asyncCache)
|
||||
|
||||
private def tryDailyPuzzle(): Fu[Option[lila.puzzle.DailyPuzzle]] =
|
||||
scala.concurrent.Future {
|
||||
Env.puzzle.daily()
|
||||
}.flatMap(identity).withTimeoutDefault(100 millis, none)(system) recover {
|
||||
Env.puzzle.daily.get.withTimeoutDefault(100 millis, none)(system) recover {
|
||||
case e: Exception =>
|
||||
lila.log("preloader").warn("daily puzzle", e)
|
||||
none
|
||||
|
@ -64,7 +62,8 @@ final class Env(
|
|||
system.actorOf(Props(new actor.Renderer), name = RendererName)
|
||||
|
||||
lila.log.boot.info("Preloading modules")
|
||||
lila.common.Chronometer.syncEffect(List(Env.socket,
|
||||
lila.common.Chronometer.syncEffect(List(
|
||||
Env.socket,
|
||||
Env.site,
|
||||
Env.tournament,
|
||||
Env.lobby,
|
||||
|
|
|
@ -38,7 +38,7 @@ object Puzzle extends LilaController {
|
|||
}
|
||||
|
||||
def daily = Open { implicit ctx =>
|
||||
OptionFuResult(env.daily() flatMap {
|
||||
OptionFuResult(env.daily.get flatMap {
|
||||
_.map(_.id) ?? env.api.puzzle.find
|
||||
}) { puzzle =>
|
||||
negotiate(
|
||||
|
@ -214,7 +214,7 @@ object Puzzle extends LilaController {
|
|||
}
|
||||
|
||||
def frame = Open { implicit ctx =>
|
||||
OptionOk(env.daily()) { daily =>
|
||||
OptionOk(env.daily.get) { daily =>
|
||||
html.puzzle.embed(daily)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ private[puzzle] final class Daily(
|
|||
f = find,
|
||||
expireAfter = _.ExpireAfterWrite(10 minutes))
|
||||
|
||||
def apply: Fu[Option[DailyPuzzle]] = cache.get
|
||||
def get: Fu[Option[DailyPuzzle]] = cache.get
|
||||
|
||||
private def find: Fu[Option[DailyPuzzle]] = (findCurrent orElse findNew) recover {
|
||||
case e: Exception =>
|
||||
|
|
|
@ -60,8 +60,7 @@ final class Env(
|
|||
puzzleColl,
|
||||
renderer,
|
||||
asyncCache = asyncCache,
|
||||
system.scheduler
|
||||
).apply _
|
||||
system.scheduler)
|
||||
|
||||
def cli = new lila.common.Cli {
|
||||
def process = {
|
||||
|
|
Loading…
Reference in a new issue