package lila.blog

import scala.concurrent.duration._

final class LastPostCache(api: BlogApi, ttl: Duration, collection: String) {

  private val cache = lila.memo.MixedCache.single[List[MiniPost]](
    api.prismicApi flatMap { prismic =>
      api.recent(prismic, none, 3) map {
        _ ?? {
          _.results.toList flatMap MiniPost.fromDocument(collection)
        }
      }
    },
    timeToLive = ttl,
    default = Nil,
    awaitTime = 1.millisecond)

  def apply = cache get true
  // def apply = List.empty[MiniPost]

  private[blog] def clear {
    cache invalidate true
  }
}

package lila.blog

import scala.concurrent.duration._

final class LastPostCache(api: BlogApi, ttl: Duration, collection: String) {

  private val cache = lila.memo.MixedCache.single[List[MiniPost]](
    api.prismicApi flatMap { prismic =>
      api.recent(prismic, none, 3) map {
        _ ?? {
          _.results.toList flatMap MiniPost.fromDocument(collection)
        }
      }
    },
    timeToLive = ttl,
    default = Nil,
    awaitTime = 1.millisecond)

  def apply = cache get true

  private[blog] def clear {
    cache invalidate true
  }
}

Revert "disable last blog posts cache"
Revert "disable last blog posts cache"

This reverts commit 7981dc342c1efa85d35b129c209ccddeb5cd2a69.
