Revert "don't cache tournaments"

This reverts commit 4c1bacb0ae.
This commit is contained in:
Thibault Duplessis 2014-04-13 13:11:22 +02:00
parent f619fe53aa
commit bfaab3943c
3 changed files with 7 additions and 3 deletions

View file

@ -29,7 +29,7 @@ object Lobby extends LilaController {
def renderHome[A](status: Results.Status)(implicit ctx: Context): Fu[SimpleResult] =
Env.current.preloader(
posts = Env.forum.recent(ctx.me, Env.team.cached.teamIds.apply),
tours = TournamentRepo.allCreatedSorted,
tours = Env.tournament.allCreatedSorted(true),
filter = Env.setup.filter
).map(_.fold(Redirect(_), {
case (preload, entries, posts, tours, featured, leaderboard, progress, puzzle) =>

View file

@ -40,7 +40,7 @@ object Tournament extends LilaController {
}
private def fetchTournaments =
repo.allCreatedSorted zip repo.started zip repo.finished(20)
env allCreatedSorted true zip repo.started zip repo.finished(20)
def show(id: String) = Open { implicit ctx =>
repo byId id flatMap {

View file

@ -25,6 +25,7 @@ final class Env(
private val settings = new {
val CollectionTournament = config getString "collection.tournament"
val MessageTtl = config duration "message.ttl"
val CreatedCacheTtl = config duration "created.cache.ttl"
val UidTimeout = config duration "uid.timeout"
val SocketTimeout = config duration "socket.timeout"
val SocketName = config getString "socket.name"
@ -75,6 +76,9 @@ final class Env(
def version(tourId: String): Fu[Int] =
socketHub ? Ask(tourId, GetVersion) mapTo manifest[Int]
val allCreatedSorted =
lila.memo.AsyncCache.single(TournamentRepo.allCreatedSorted, timeToLive = CreatedCacheTtl)
def cli = new lila.common.Cli {
import tube.tournamentTube
def process = {
@ -95,7 +99,7 @@ final class Env(
organizer -> actorApi.StartedTournaments
}
scheduler.message(1 minute) {
scheduler.message(5 minutes) {
tournamentScheduler -> actorApi.ScheduleNow
}
tournamentScheduler ! actorApi.ScheduleNow