public async Task <IActionResult> GetEntity([FromQuery] string url) { if (string.IsNullOrEmpty(url)) { return(BadRequest()); } var key = RedisKeyGenerator.Concat(EntityKey, url); var res = memoryCache.Get <AnfComicEntityTruck>(key); if (res != null) { await comicRankService.AddScopeAsync(url); return(Ok(res)); } res = await rootFetcher.FetchEntityAsync(url); if (res != null) { await comicRankService.AddScopeAsync(url); memoryCache.Set(key, res, new MemoryCacheEntryOptions { SlidingExpiration = CacheTime }); } return(Ok(res)); }
protected override async Task <ComicEntity> MakeEntityAsync(string address) { var entity = await rootFetcher.FetchEntityAsync(address); if (entity is null) { return(null); } await comicRankService.AddScopeAsync(address); return(new ComicEntity { Chapters = entity.Chapters, ComicUrl = entity.ComicUrl, Descript = entity.Descript, ImageUrl = entity.ImageUrl, Name = entity.Name }); }