Merge pull request #115 from jcole/master
Added a few methods to SDImageCache to get number of items in file cache and memory cache, and size of items in memory
This commit is contained in:
commit
af3924c447
|
@ -122,4 +122,19 @@
|
|||
*/
|
||||
- (int)getSize;
|
||||
|
||||
/**
|
||||
* Get the number of images in the disk cache
|
||||
*/
|
||||
- (int)getDiskCount;
|
||||
|
||||
/**
|
||||
* Get the total size of images in memory cache
|
||||
*/
|
||||
- (int)getMemorySize;
|
||||
|
||||
/**
|
||||
* Get the number of images in the memory cache
|
||||
*/
|
||||
- (int)getMemoryCount;
|
||||
|
||||
@end
|
||||
|
|
|
@ -360,4 +360,34 @@ static SDImageCache *instance;
|
|||
return size;
|
||||
}
|
||||
|
||||
- (int)getDiskCount
|
||||
{
|
||||
int count = 0;
|
||||
NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:diskCachePath];
|
||||
for (NSString *fileName in fileEnumerator)
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
- (int)getMemorySize
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
for(id key in [memCache allKeys])
|
||||
{
|
||||
UIImage *img = [memCache valueForKey:key];
|
||||
size += [UIImageJPEGRepresentation(img, 0) length];
|
||||
};
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
- (int)getMemoryCount
|
||||
{
|
||||
return [[memCache allKeys] count];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue