rethink image cache (#498)

This commit is contained in:
Aria Moradi
2023-02-12 18:33:36 +03:30
committed by GitHub
parent b10062c73d
commit 54bbb5e384
11 changed files with 64 additions and 80 deletions

View File

@@ -15,7 +15,6 @@ import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass
import suwayomi.tachidesk.server.JavalinSetup.future
import suwayomi.tachidesk.server.util.handler
import suwayomi.tachidesk.server.util.pathParam
import suwayomi.tachidesk.server.util.queryParam
import suwayomi.tachidesk.server.util.withOperation
object ExtensionController {
@@ -141,16 +140,15 @@ object ExtensionController {
/** icon for extension named `apkName` */
val icon = handler(
pathParam<String>("apkName"),
queryParam("useCache", true),
documentWith = {
withOperation {
summary("Extension icon")
description("Icon for extension named `apkName`")
}
},
behaviorOf = { ctx, apkName, useCache ->
behaviorOf = { ctx, apkName ->
ctx.future(
future { Extension.getExtensionIcon(apkName, useCache) }
future { Extension.getExtensionIcon(apkName) }
.thenApply {
ctx.header("content-type", it.second)
it.first

View File

@@ -81,16 +81,15 @@ object MangaController {
/** manga thumbnail */
val thumbnail = handler(
pathParam<Int>("mangaId"),
queryParam("useCache", true),
documentWith = {
withOperation {
summary("Get a manga thumbnail")
description("Get a manga thumbnail from the source or the cache.")
}
},
behaviorOf = { ctx, mangaId, useCache ->
behaviorOf = { ctx, mangaId ->
ctx.future(
future { Manga.getMangaThumbnail(mangaId, useCache) }
future { Manga.getMangaThumbnail(mangaId) }
.thenApply {
ctx.header("content-type", it.second)
val httpCacheSeconds = 1.days.inWholeSeconds
@@ -375,16 +374,15 @@ object MangaController {
pathParam<Int>("mangaId"),
pathParam<Int>("chapterIndex"),
pathParam<Int>("index"),
queryParam("useCache", true),
documentWith = {
withOperation {
summary("Get a chapter page")
description("Get a chapter page for a given index. Cache use can be disabled so it only retrieves it directly from the source.")
}
},
behaviorOf = { ctx, mangaId, chapterIndex, index, useCache ->
behaviorOf = { ctx, mangaId, chapterIndex, index ->
ctx.future(
future { Page.getPageImage(mangaId, chapterIndex, index, useCache) }
future { Page.getPageImage(mangaId, chapterIndex, index) }
.thenApply {
ctx.header("content-type", it.second)
val httpCacheSeconds = 1.days.inWholeSeconds