Skip to content

Commit

Permalink
Add isCachingEnabled to know if a section has caching enabled or not
Browse files Browse the repository at this point in the history
  • Loading branch information
Galarzaa90 committed Aug 1, 2024
1 parent 09a369d commit 615bc73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ public open class TibiaKtClient constructor(
cacheAge = 0,
fetchingTime = fetchingTime,
parsingTime = parsingTime,
data = baseHighscores!!.copy(entries = entries)
data = baseHighscores!!.copy(entries = entries),
isCachingEnabled = false,
)
}

Expand Down Expand Up @@ -661,7 +662,8 @@ public open class TibiaKtClient constructor(
cacheAge = headers["Age"]?.toInt() ?: 0,
fetchingTime = fetchingTime,
parsingTime = parsingTime,
data = data
data = data,
isCachingEnabled = headers["CF-Cache-Status"] != "DYNAMIC"
)

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2023 Allan Galarza
* Copyright © 2024 Allan Galarza
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,8 +25,9 @@ import kotlinx.serialization.Serializable
* A response from Tibia.com.
*
* @property timestamp the time when the request was done.
* @property isCached Whether the response is cached or not.
* @property isCached Whether the current data is cached or not.
* @property cacheAge How old is the cached response, in seconds.
* @property isCachingEnabled Whether the response has caching enabled or not.
* @property fetchingTime The time it took to fetch the content from Tibia.com in seconds.
* @property parsingTime The time it took to parse the content into data in seconds.
* @property data The data parsed from Tibia.com.
Expand All @@ -37,6 +38,7 @@ public data class TibiaResponse<T>(
val timestamp: Instant,
val isCached: Boolean,
val cacheAge: Int,
val isCachingEnabled: Boolean,
val fetchingTime: Double,
val parsingTime: Double,
val data: T,
Expand Down

0 comments on commit 615bc73

Please sign in to comment.