Add caching for user files

This commit is contained in:
2024-09-23 17:24:55 +07:00
parent 1feeafe7de
commit 59d4154ef0
15 changed files with 318 additions and 91 deletions

View File

@ -29,19 +29,27 @@ func PUT(w http.ResponseWriter, r *http.Request) {
return
}
err = app.Server.Service.DeleteFileCache(r.Context(), fileID)
err = app.Server.Service.RemoveFileCache(r.Context(), fileID)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
app.Server.Logger.Error(err.Error())
return
}
userFile, err := app.Server.Service.GetUserFile(r.Context(), file.ID)
err = app.Server.Service.RemoveUserFilesCache(r.Context(), userSession.UserID)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
app.Server.Logger.Error(err.Error())
return
}
userFile, err := app.Server.Service.GetFileDetail(r.Context(), file.ID)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
app.Server.Logger.Error(err.Error())
return
}
component := fileView.JustFile(*userFile)
err = component.Render(r.Context(), w)
if err != nil {