예제 #1
0
 public NuGetCatalog(DiskCacheConfig config)
 {
     this.config = config;
     this.catalogIndexFileName = Path.Combine(config.CacheRoot, "catalogIndex.json");
     this.indexFileName        = Path.Combine(config.CacheRoot, "index.json");
     pagePathFormatStr         = Path.Combine(config.CacheRoot, "pages", "{0}");
 }
 /// <summary>
 /// Returns the <see cref="IDiskStorage"/> from the <see cref="DiskCacheConfig"/>.
 /// </summary>
 public IDiskStorage Get(DiskCacheConfig diskCacheConfig)
 {
     return(new DynamicDefaultDiskStorage(
                diskCacheConfig.Version,
                diskCacheConfig.BaseDirectoryPathSupplier,
                diskCacheConfig.BaseDirectoryName,
                diskCacheConfig.CacheErrorLogger));
 }
예제 #3
0
 public NuGetDependencies(InMemoryIndex index, Config config)
 {
     this.index  = index;
     this.config = config.DiskCache;
     this.ignoreDuplicatePackages = config.IgnoreDuplicatePackages;
     this.versionResolver         = new PackageVersionResolver(index);
     this.detailsPathFormatStr    = Path.Combine(this.config.CacheRoot, "packageDetails", "{0}_{1}.json");
     this.resolvedPathFormatStr   = Path.Combine(this.config.CacheRoot, "resolvedDependencies", "{0}_{1}.json");
     this.packagePolicies         = PackagePolicies.LoadFrom(config.PackagePolicies);
 }
예제 #4
0
        /// <summary>
        /// Gets the small image file cache.
        /// </summary>
        public IFileCache GetSmallImageFileCache()
        {
            if (_smallImageFileCache == null)
            {
                DiskCacheConfig diskCacheConfig = _config.SmallImageDiskCacheConfig;
                _smallImageFileCache = _config.FileCacheFactory.Get(diskCacheConfig);
            }

            return(_smallImageFileCache);
        }
예제 #5
0
        /// <summary>
        /// Gets the main file cache.
        /// </summary>
        public IFileCache GetMainFileCache()
        {
            if (_mainFileCache == null)
            {
                DiskCacheConfig diskCacheConfig = _config.MainDiskCacheConfig;
                _mainFileCache = _config.FileCacheFactory.Get(diskCacheConfig);
            }

            return(_mainFileCache);
        }
        public DependencyScanner(INpm npm, IFileAccess fileSystem, PackagePolicies packagePolicies, DiskCacheConfig config)
        {
            this.fileSystem      = fileSystem;
            this.npm             = npm;
            this.versionResolver = new NpmVersionResolver(npm, config);
            this.packagePolicies = packagePolicies;
            this.config          = config;

            this.detailsPathFormatStr  = Path.Combine(this.config.CacheRoot, "packageDetails", "{0}_{1}.json");
            this.resolvedPathFormatStr = Path.Combine(this.config.CacheRoot, "resolvedDependencies", "{0}_{1}.json");
        }
        private ImagePipelineConfig(Builder builder)
        {
            _animatedImageFactory            = builder.AnimatedImageFactory;
            _bitmapMemoryCacheParamsSupplier = builder.BitmapMemoryCacheParamsSupplier ??
                                               new DefaultBitmapMemoryCacheParamsSupplier();

            _bitmapConfig = builder.BitmapConfig == default(BitmapPixelFormat) ?
                            BitmapPixelFormat.Bgra8 : builder.BitmapConfig;

            _cacheKeyFactory = builder.CacheKeyFactory ?? DefaultCacheKeyFactory.Instance;

            _decodeMemoryFileEnabled = builder.IsDecodeMemoryFileEnabled;
            _fileCacheFactory        = builder.FileCacheFactory ??
                                       new DiskStorageCacheFactory(new DynamicDefaultDiskStorageFactory());

            _downsampleEnabled = builder.IsDownsampleEnabled;
            _encodedMemoryCacheParamsSupplier = builder.EncodedMemoryCacheParamsSupplier ??
                                                new DefaultEncodedMemoryCacheParamsSupplier();

            _imageCacheStatsTracker = builder.ImageCacheStatsTracker ??
                                      NoOpImageCacheStatsTracker.Instance;

            _imageDecoder = builder.ImageDecoder;
            _isPrefetchEnabledSupplier = builder.IsPrefetchEnabledSupplier ??
                                         new SupplierImpl <bool>(
                () =>
            {
                return(true);
            });

            _mainDiskCacheConfig = builder.MainDiskCacheConfig ??
                                   GetDefaultMainDiskCacheConfig();

            _memoryTrimmableRegistry = builder.MemoryTrimmableRegistry ??
                                       NoOpMemoryTrimmableRegistry.Instance;

            _networkFetcher        = builder.NetworkFetcher ?? new HttpUrlConnectionNetworkFetcher();
            _platformBitmapFactory = builder.PlatformBitmapFactory;
            _poolFactory           = builder.PoolFactory ?? new PoolFactory(PoolConfig.NewBuilder().Build());
            _progressiveJpegConfig = builder.ProgressiveJpegConfig == default(IProgressiveJpegConfig) ?
                                     new SimpleProgressiveJpegConfig() : builder.ProgressiveJpegConfig;

            _requestListeners = builder.RequestListeners ?? new HashSet <IRequestListener>();
            _resizeAndRotateEnabledForNetwork = builder.ResizeAndRotateEnabledForNetwork;
            _smallImageDiskCacheConfig        = builder.SmallImageDiskCacheConfig ?? _mainDiskCacheConfig;

            // Below this comment can't be built in alphabetical order, because of dependencies
            int numCpuBoundThreads = _poolFactory.FlexByteArrayPoolMaxNumThreads;

            _executorSupplier = builder.ExecutorSupplier ??
                                new DefaultExecutorSupplier(numCpuBoundThreads);

            _imagePipelineExperiments = builder.Experiment.Build();
        }
예제 #8
0
        public void Initialize()
        {
            // Initializes the IFileCache
            _fileCacheFactory = new DiskStorageCacheFactory(new DynamicDefaultDiskStorageFactory());
            _fileCache        = _fileCacheFactory.Get(DiskCacheConfig.NewBuilder().Build());

            // Initializes the IPooledByteBufferFactory and PooledByteStreams
            _poolFactory       = new PoolFactory(PoolConfig.NewBuilder().Build());
            _byteBufferFactory = _poolFactory.PooledByteBufferFactory;
            _pooledByteStreams = _poolFactory.PooledByteStreams;

            // Initializes the IPooledByteBuffer from an image
            var file = StorageFile.GetFileFromApplicationUriAsync(
                new Uri("ms-appx:///Assets/SplashScreen.scale-200.png")).GetAwaiter().GetResult();

            using (var stream = file.OpenReadAsync().GetAwaiter().GetResult())
            {
                _pooledByteBuffer = _byteBufferFactory.NewByteBuffer(
                    ByteStreams.ToByteArray(stream.AsStream()));
            }

            _closeableReference = CloseableReference <IPooledByteBuffer> .of(_pooledByteBuffer);

            _encodedImage           = new EncodedImage(_closeableReference);
            _stagingArea            = StagingArea.Instance;
            _imageCacheStatsTracker = NoOpImageCacheStatsTracker.Instance;

            // Initializes the cache keys
            IList <ICacheKey> keys = new List <ICacheKey>();

            keys.Add(new SimpleCacheKey("http://test.uri"));
            keys.Add(new SimpleCacheKey("http://tyrone.uri"));
            keys.Add(new SimpleCacheKey("http://ian.uri"));
            _cacheKey = new MultiCacheKey(keys);

            // Initializes the executors
            _isCancelled           = new AtomicBoolean(false);
            _readPriorityExecutor  = Executors.NewFixedThreadPool(1);
            _writePriorityExecutor = Executors.NewFixedThreadPool(1);

            // Initializes the disk cache
            _bufferedDiskCache = new BufferedDiskCache(
                _fileCache,
                _byteBufferFactory,
                _pooledByteStreams,
                _readPriorityExecutor,
                _writePriorityExecutor,
                _imageCacheStatsTracker);
        }
예제 #9
0
        public async Task TestSyncDiskCacheCheck()
        {
            await _bufferedDiskCache.Put(_cacheKey, _encodedImage);

            _fileCache = _fileCacheFactory.Get(DiskCacheConfig.NewBuilder().Build());
            _stagingArea.ClearAll();
            _bufferedDiskCache = new BufferedDiskCache(
                _fileCache,
                _byteBufferFactory,
                _pooledByteStreams,
                _readPriorityExecutor,
                _writePriorityExecutor,
                _imageCacheStatsTracker);
            Assert.IsTrue(_bufferedDiskCache.DiskCheckSync(_cacheKey));
        }
        /// <summary>
        /// Builds the <see cref="DiskStorageCache"/>.
        /// </summary>
        public static DiskStorageCache BuildDiskStorageCache(
            DiskCacheConfig diskCacheConfig,
            IDiskStorage diskStorage)
        {
            Params parameters = new Params(
                diskCacheConfig.MinimumSizeLimit,
                diskCacheConfig.LowDiskSpaceSizeLimit,
                diskCacheConfig.DefaultSizeLimit);

            return(new DiskStorageCache(
                       diskStorage,
                       diskCacheConfig.EntryEvictionComparatorSupplier,
                       parameters,
                       diskCacheConfig.CacheEventListener,
                       diskCacheConfig.CacheErrorLogger,
                       diskCacheConfig.DiskTrimmableRegistry,
                       diskCacheConfig.IndexPopulateAtStartupEnabled));
        }
예제 #11
0
 public NpmVersionResolver(INpm npm, DiskCacheConfig config)
 {
     this.npm = npm;
     npmOverviewPathFormatStr = Path.Combine(config.CacheRoot, "npmOverview", "{0}");
     this.cachePolicy         = config.NpmPackages;
 }
 /// <summary>
 /// Sets the small image disk cache configuration.
 /// </summary>
 public Builder SetSmallImageDiskCacheConfig(DiskCacheConfig smallImageDiskCacheConfig)
 {
     SmallImageDiskCacheConfig = smallImageDiskCacheConfig;
     return(this);
 }
 /// <summary>
 /// Sets the main disk cache configuration.
 /// </summary>
 public Builder SetMainDiskCacheConfig(DiskCacheConfig mainDiskCacheConfig)
 {
     MainDiskCacheConfig = mainDiskCacheConfig;
     return(this);
 }
 private static DiskCacheConfig GetDefaultMainDiskCacheConfig()
 {
     return(DiskCacheConfig.NewBuilder().Build());
 }
예제 #15
0
 /// <summary>
 /// Creates a new <see cref="DiskStorageCache"/> from
 /// the given <see cref="DiskCacheConfig"/>.
 ///
 /// @deprecated use
 /// <see cref="DiskStorageCacheFactory.BuildDiskStorageCache"/>.
 /// </summary>
 public static DiskStorageCache BuildDiskStorageCache(
     DiskCacheConfig diskCacheConfig,
     IDiskStorage diskStorage)
 {
     return(DiskStorageCacheFactory.BuildDiskStorageCache(diskCacheConfig, diskStorage));
 }
 /// <summary>
 /// Returns the <see cref="IFileCache"/> from the <see cref="DiskCacheConfig"/>.
 /// </summary>
 public IFileCache Get(DiskCacheConfig diskCacheConfig)
 {
     return(BuildDiskStorageCache(diskCacheConfig, _diskStorageFactory.Get(diskCacheConfig)));
 }