Small refactors to http client and caching
This commit is contained in:
1 parent
61327401b0
commit
9ae8601a32
5 files changed
+22
-27
No files matched your search
@@ -98,11 +98,7 @@ namespace Invidious
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.QueryParam("q", q)
|
||||
' 5 hours cache. Videos should expire in 6 hours, but since we don't
|
||||
' have the exact expiration time, we'll use 5 hours. Invidious currently
|
||||
' Does a fresh fetch if the cache is older than 10 minutes.
|
||||
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
|
||||
request.CacheSeconds(60 * 60 * 5)
|
||||
request.CacheSeconds(60 * 60 * 24)
|
||||
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
@@ -116,7 +112,11 @@ namespace Invidious
|
||||
|
||||
request = HttpClient.Get(url)
|
||||
request.QueryParams(m.DefaultQueryParams())
|
||||
request.CacheSeconds(60 * 60 * 6)' 6 hours
|
||||
' 5 hours cache. Videos should expire in 6 hours, but since we don't
|
||||
' have the exact expiration time, we'll use 5 hours. Invidious currently
|
||||
' Does a fresh fetch if the cache is older than 10 minutes.
|
||||
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
|
||||
request.CacheSeconds(60 * 60 * 5)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
return request.Await()
|
||||
@@ -232,12 +232,8 @@ namespace Invidious
|
||||
else
|
||||
request.QueryParam(queryParamKey, queryParam.default)
|
||||
end if
|
||||
else if IsArray(queryParam.default)
|
||||
if queryParam.arrayType = "repeat"
|
||||
request.QueryParamArray(queryParamKey, queryParam.default, HttpClient.QueryParamArrayType.Repeated)
|
||||
else if queryParam.arrayType = "comma-separated"
|
||||
request.QueryParamArray(queryParamKey, queryParam.default, HttpClient.QueryParamArrayType.CommaSeparated)
|
||||
end if
|
||||
else if IsArray(queryParam.default) and queryParam.arrayType <> invalid
|
||||
request.QueryParamArray(queryParamKey, queryParam.default, queryParam.arrayType)
|
||||
else
|
||||
request.QueryParam(queryParamKey, queryParam.default)
|
||||
end if
|
||||
|
||||
Reference in new issue
Block a user