Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private async Task <LanguageConfig> GetLanguageListInternalAsync(string shortName, string version)
        {
            var project = await _projectRepository.GetByShortNameAsync(shortName);

            var store = _documentSource.Create(project.DocumentStoreType);

            async Task <LanguageConfig> GetLanguagesAsync()
            {
                return(await store.GetLanguageListAsync(project, version));
            }

            return(await LanguageCache.GetOrAddAsync(
                       CacheKeyGenerator.GenerateProjectLanguageCacheKey(project),
                       GetLanguagesAsync,
                       () => new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(24)
            }
                       ));
        }