diff options
author | crupest <crupest@outlook.com> | 2020-03-13 17:58:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-13 17:58:32 +0800 |
commit | 636cf3839d92e884987e4e3aec7f23953d02fe37 (patch) | |
tree | dd53c68673c84a0cbf157ef0378dbdc1b4610d53 /Timeline/Controllers/TimelineController.cs | |
parent | 8a1ecbf49673cb2bed538ac8bc4e82691b90d973 (diff) | |
download | timeline-636cf3839d92e884987e4e3aec7f23953d02fe37.tar.gz timeline-636cf3839d92e884987e4e3aec7f23953d02fe37.tar.bz2 timeline-636cf3839d92e884987e4e3aec7f23953d02fe37.zip |
Add cache for timeline post data.
Diffstat (limited to 'Timeline/Controllers/TimelineController.cs')
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index 58390c29..8bc0345f 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Timeline.Filters;
+using Timeline.Helpers;
using Timeline.Models;
using Timeline.Models.Http;
using Timeline.Models.Validation;
@@ -114,7 +115,6 @@ namespace Timeline.Controllers return result;
}
- // TODO: Make cache available.
[HttpGet("timelines/{name}/posts/{id}/data")]
public async Task<ActionResult<List<TimelinePostInfo>>> PostDataGet([FromRoute][GeneralTimelineName] string name, [FromRoute] long id)
{
@@ -125,8 +125,11 @@ namespace Timeline.Controllers try
{
- var data = await _service.GetPostData(name, id);
- return File(data.Data, data.Type, data.LastModified, new EntityTagHeaderValue($"\"{data.ETag}\""));
+ return await DataCacheHelper.GenerateActionResult(this, () => _service.GetPostDataETag(name, id), async () =>
+ {
+ var data = await _service.GetPostData(name, id);
+ return data;
+ });
}
catch (TimelinePostNotExistException)
{
|