Пример #1
0
        public async Task Clear(ClearCacheModel model)
        {
            if (model.Password.IsNullOrEmpty())
            {
                throw new UserFriendlyException("Password can not be null or empty!");
            }

            if (model.Caches.IsNullOrEmpty())
            {
                throw new UserFriendlyException("Caches can not be null or empty!");
            }

            await CheckPassword(model.Password);

            var caches = _cacheManager.GetAllCaches().Where(c => model.Caches.Contains(c.Name));
            foreach (var cache in caches)
            {
                await cache.ClearAsync();
            }
        }
        public async Task Clear(ClearCacheModel model)
        {
            if (model.Password.IsNullOrEmpty())
            {
                throw new UserFriendlyException("Password can not be null or empty!");
            }

            //TODO: Define a password setting and check the password!

            if (model.Caches.IsNullOrEmpty())
            {
                await _cacheProvider.ClearAllCacheStoresAsync();
                return;
            }
            
            foreach (var cache in model.Caches)
            {
                await _cacheProvider.ClearCacheStoreAsync(cache);
            }
        }
Пример #3
0
        public async Task Clear(ClearCacheModel model)
        {
            if (model.Password.IsNullOrEmpty())
            {
                throw new UserFriendlyException("Password can not be null or empty!");
            }

            if (model.Caches.IsNullOrEmpty())
            {
                throw new UserFriendlyException("Caches can not be null or empty!");
            }

            await CheckPassword(model.Password);

            var caches = _cacheManager.GetAllCaches().Where(c => model.Caches.Contains(c.Name));

            foreach (var cache in caches)
            {
                await cache.ClearAsync();
            }
        }