|
@@ -1,5 +1,6 @@
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.Extensions.Caching.Memory;
|
|
|
using System.Threading.Tasks;
|
|
|
using Website.Data;
|
|
|
using Website.Models.Mailboxes;
|
|
@@ -9,10 +10,12 @@ namespace Website.Controllers {
|
|
|
public class Admin : Controller {
|
|
|
private readonly IApiKeyManager _apiKeyManager;
|
|
|
private readonly IMailboxesApi _mailboxesApi;
|
|
|
+ private readonly IMemoryCache _cache;
|
|
|
|
|
|
- public Admin(IApiKeyManager apiKeyManager, IMailboxesApi mailboxesApi) {
|
|
|
+ public Admin(IApiKeyManager apiKeyManager, IMailboxesApi mailboxesApi, IMemoryCache cache) {
|
|
|
_apiKeyManager = apiKeyManager;
|
|
|
_mailboxesApi = mailboxesApi;
|
|
|
+ _cache = cache;
|
|
|
}
|
|
|
|
|
|
public async Task<IActionResult> ApiKeys() {
|
|
@@ -65,5 +68,15 @@ namespace Website.Controllers {
|
|
|
await _mailboxesApi.CreateAlias(alias);
|
|
|
return RedirectToAction(nameof(Mailboxes));
|
|
|
}
|
|
|
+
|
|
|
+ [HttpGet]
|
|
|
+ public async Task<IActionResult> Cache() => View(_cache);
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public async Task<IActionResult> Cache(bool reset) {
|
|
|
+ if (reset && _cache is MemoryCache cache)
|
|
|
+ cache.Compact(1.0);
|
|
|
+ return RedirectToAction(nameof(Cache));
|
|
|
+ }
|
|
|
}
|
|
|
}
|