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> /// Returns whether the image is stored in the disk cache. /// Performs disk cache check synchronously. It is not /// recommended to use this unless you know what exactly /// you are doing. Disk cache check is a costly operation, /// the call will block the caller thread until the cache /// check is completed. /// </summary> /// <param name="imageRequest"> /// The image request to be looked up. /// </param> /// <returns> /// true if the image was found in the disk cache, /// false otherwise. /// </returns> public bool IsInDiskCacheSync(ImageRequest imageRequest) { ICacheKey cacheKey = _cacheKeyFactory.GetEncodedCacheKey(imageRequest, null); CacheChoice cacheChoice = imageRequest.CacheChoice; switch (cacheChoice) { case CacheChoice.DEFAULT: return(_mainBufferedDiskCache.DiskCheckSync(cacheKey)); case CacheChoice.SMALL: return(_smallImageBufferedDiskCache.DiskCheckSync(cacheKey)); default: return(false); } }