/// <summary> /// Creates new LimitedStorageCache instance /// </summary> /// <param name="isf">StorageFolder instance to work with file system</param> /// <param name="cacheDirectory">Directory to store cache, starting with two slashes "\\"</param> /// <param name="cacheFileNameGenerator">ICacheFileNameGenerator instance to generate cache filenames</param> /// <param name="cacheLimitInBytes">Limit of total cache size in bytes, for example 10 mb == 10 * 1024 * 1024</param> /// <param name="cacheMaxLifetimeInMillis">Cache max lifetime in millis, for example two weeks = 2 * 7 * 24 * 60 * 60 * 1000; default value == one week; pass value <= 0 to disable max cache lifetime</param> public LimitedStorageCache(StorageFolder isf, string cacheDirectory, ICacheGenerator cacheFileNameGenerator, long cacheLimitInBytes, long cacheMaxLifetimeInMillis = DefaultCacheMaxLifetimeInMillis) : base(isf, cacheDirectory, cacheFileNameGenerator, cacheMaxLifetimeInMillis) { _cacheLimitInBytes = cacheLimitInBytes; BeginCountCurrentCacheSize(); }
protected StorageCacheBase(StorageFolder sf, string cacheDirectory, ICacheGenerator cacheFileNameGenerator, long cacheMaxLifetimeInMillis = DefaultCacheMaxLifetimeInMillis) { if (sf == null) { throw new ArgumentNullException("isf"); } if (string.IsNullOrEmpty(cacheDirectory)) { throw new ArgumentException("cacheDirectory name could not be null or empty"); } if (cacheDirectory.StartsWith("\\")) { throw new ArgumentException("cacheDirectory name shouldn't starts with double slashes: \\"); } if (cacheFileNameGenerator == null) { throw new ArgumentNullException("cacheFileNameGenerator"); } SF = sf; CacheDirectory = cacheDirectory; CacheFileNameGenerator = cacheFileNameGenerator; CacheMaxLifetimeInMillis = cacheMaxLifetimeInMillis; // Creating cache directory if it not exists SF.CreateFolderAsync(CacheDirectory).AsTask(); }
/// <summary> /// Creates instance /// </summary> /// <param name="isf">StorageFolder instance to work with file system</param> /// <param name="cacheDirectory">Directory to store cache, starting with two slashes "\\"</param> /// <param name="cacheFileNameGenerator">ICacheFileNameGenerator instance to generate cache filenames</param> /// <param name="cacheMaxLifetimeInMillis">Cache max lifetime in millis, for example two weeks = 2 * 7 * 24 * 60 * 60 * 1000; default value == 0; pass value <= 0 to disable max cache lifetime</param> public UnlimitedStorageCache(StorageFolder isf, string cacheDirectory, ICacheGenerator cacheFileNameGenerator, long cacheMaxLifetimeInMillis = 0) : base(isf, cacheDirectory, cacheFileNameGenerator, cacheMaxLifetimeInMillis) { }
/// <summary> /// 是否支持最新的Gif Api /// </summary> /// <param name="isSupported"></param> /// <returns></returns> public Builder LimitedStorageCache(StorageFolder isf, string cacheDirectory, ICacheGenerator cacheFileNameGenerator, long cacheLimitInBytes) { StorageCacheImpl = new LimitedStorageCache(isf, cacheDirectory, cacheFileNameGenerator, cacheLimitInBytes); return(this); }