mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-14 14:20:29 +05:30
Cache based on playlistId length.
This commit is contained in:
parent
ad89de49a0
commit
dc0e4c1bbb
@ -17,6 +17,7 @@ import me.kavin.piped.utils.*;
|
|||||||
import me.kavin.piped.utils.resp.ErrorResponse;
|
import me.kavin.piped.utils.resp.ErrorResponse;
|
||||||
import me.kavin.piped.utils.resp.LoginRequest;
|
import me.kavin.piped.utils.resp.LoginRequest;
|
||||||
import me.kavin.piped.utils.resp.SubscriptionUpdateRequest;
|
import me.kavin.piped.utils.resp.SubscriptionUpdateRequest;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -129,8 +130,10 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||||||
}
|
}
|
||||||
})).map(GET, "/playlists/:playlistId", AsyncServlet.ofBlocking(executor, request -> {
|
})).map(GET, "/playlists/:playlistId", AsyncServlet.ofBlocking(executor, request -> {
|
||||||
try {
|
try {
|
||||||
return getJsonResponse(ResponseHelper.playlistResponse(request.getPathParameter("playlistId")),
|
var playlistId = request.getPathParameter("playlistId");
|
||||||
"public, max-age=600", true);
|
var cache = StringUtils.isBlank(playlistId) || playlistId.length() != 36 ?
|
||||||
|
"public, max-age=600" : "private";
|
||||||
|
return getJsonResponse(ResponseHelper.playlistResponse(playlistId), cache, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return getErrorResponse(e, request.getPath());
|
return getErrorResponse(e, request.getPath());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user