Merge pull request #2299 from dreampiggy/feature_cache_namespace_prefix
Add the ability to custom the cache namespace prefix
This commit is contained in:
commit
e8ce9e89c5
|
@ -59,7 +59,11 @@
|
|||
diskCacheDirectory:(nonnull NSString *)directory
|
||||
config:(nullable SDImageCacheConfig *)config {
|
||||
if ((self = [super init])) {
|
||||
NSString *fullNamespace = [@"com.hackemist.SDImageCache." stringByAppendingString:ns];
|
||||
NSString *namespacePrefix = config.namespacePrefix;
|
||||
if (!namespacePrefix) {
|
||||
namespacePrefix = @"";
|
||||
}
|
||||
NSString *fullNamespace = [namespacePrefix stringByAppendingString:ns];
|
||||
|
||||
// Create IO serial queue
|
||||
_ioQueue = dispatch_queue_create("com.hackemist.SDImageCache", DISPATCH_QUEUE_SERIAL);
|
||||
|
|
|
@ -72,6 +72,12 @@
|
|||
*/
|
||||
@property (assign, nonatomic) NSUInteger maxMemoryCount;
|
||||
|
||||
/**
|
||||
* The namespace prefix of cache. It's used to prefix the namespace you provide to the caches's initializer. You 'd better name it with reverse domain name notation and keep the final dot.
|
||||
* Defautls to `com.hackemist.SDImageCache.`, which will prefix your namespace such as `default` to final `com.hackemist.SDImageCache.default`. If you specify nil, it will be treated equals to an empty string.
|
||||
*/
|
||||
@property (copy, nonatomic, nullable) NSString *namespacePrefix;
|
||||
|
||||
/**
|
||||
* The custom file manager for disk cache. Pass nil to let disk cache choose the proper file manager.
|
||||
* Defaults to nil.
|
||||
|
|
|
@ -32,6 +32,7 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
|
|||
_diskCacheWritingOptions = NSDataWritingAtomic;
|
||||
_maxCacheAge = kDefaultCacheMaxCacheAge;
|
||||
_maxCacheSize = 0;
|
||||
_namespacePrefix = @"com.hackemist.SDImageCache.";
|
||||
_memoryCacheClass = [SDMemoryCache class];
|
||||
_diskCacheClass = [SDDiskCache class];
|
||||
}
|
||||
|
@ -49,6 +50,7 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
|
|||
config.maxCacheSize = self.maxCacheSize;
|
||||
config.maxMemoryCost = self.maxMemoryCost;
|
||||
config.maxMemoryCount = self.maxMemoryCount;
|
||||
config.namespacePrefix = [self.namespacePrefix copyWithZone:zone];
|
||||
config.fileManager = self.fileManager; // NSFileManager does not conform to NSCopying, just pass the reference
|
||||
config.memoryCacheClass = self.memoryCacheClass;
|
||||
config.diskCacheClass = self.diskCacheClass;
|
||||
|
|
Loading…
Reference in New Issue