aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-13 18:09:50 +0800
committerGitHub <noreply@github.com>2020-03-13 18:09:50 +0800
commit067ef1edcb4409feda25a9356d49b146a9fd884b (patch)
tree23167ac72ad2a0a878eacbfec7fdd9b8b4a81c55 /Timeline/Controllers/TimelineController.cs
parent904f98bda60b3bd92331aacde3771dedde62d2b5 (diff)
parent1af4f51abcd09be68bc0e2ad77b163569a50a6b3 (diff)
downloadtimeline-067ef1edcb4409feda25a9356d49b146a9fd884b.tar.gz
timeline-067ef1edcb4409feda25a9356d49b146a9fd884b.tar.bz2
timeline-067ef1edcb4409feda25a9356d49b146a9fd884b.zip
Merge pull request #71 from crupest/cache
Add cache support for timeline post data.
Diffstat (limited to 'Timeline/Controllers/TimelineController.cs')
-rw-r--r--Timeline/Controllers/TimelineController.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs
index 58390c29..f1781ff3 100644
--- a/Timeline/Controllers/TimelineController.cs
+++ b/Timeline/Controllers/TimelineController.cs
@@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
-using Microsoft.Net.Http.Headers;
using System;
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 +114,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 +124,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)
{