public async Task ClearCacheAsync(ClearCacheInput input) { var project = await _projectRepository.GetAsync(input.ProjectId); var languageCacheKey = CacheKeyGenerator.GenerateProjectLanguageCacheKey(project); await _languageCache.RemoveAsync(languageCacheKey, true); var versionCacheKey = CacheKeyGenerator.GenerateProjectVersionsCacheKey(project); await _versionCache.RemoveAsync(versionCacheKey, true); var documents = await _documentRepository.GetListByProjectId(project.Id); foreach (var document in documents) { var documentUpdateInfoCacheKey = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey( project: project, documentName: document.Name, languageCode: document.LanguageCode, version: document.Version ); await _documentUpdateCache.RemoveAsync(documentUpdateInfoCacheKey); document.LastCachedTime = DateTime.MinValue; await _documentRepository.UpdateAsync(document); } }
public async Task <ListResultDto <VersionInfoDto> > GetVersionsAsync(string shortName) { var project = await _projectRepository.GetByShortNameAsync(shortName); var versions = await _versionCache.GetOrAddAsync( CacheKeyGenerator.GenerateProjectVersionsCacheKey(project), () => GetVersionsAsync(project), () => new DistributedCacheEntryOptions { //TODO: Configurable? AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(12), SlidingExpiration = TimeSpan.FromMinutes(60) } ); return(new ListResultDto <VersionInfoDto>( ObjectMapper.Map <List <VersionInfo>, List <VersionInfoDto> >(versions) )); }