From 9d52266f823daf5cb83e3eebe1b9f57594bc9d4a Mon Sep 17 00:00:00 2001 From: matt handler Date: Wed, 20 Apr 2011 14:39:20 -0400 Subject: first commit --- Classes/HJMOFileCache.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 Classes/HJMOFileCache.h (limited to 'Classes/HJMOFileCache.h') diff --git a/Classes/HJMOFileCache.h b/Classes/HJMOFileCache.h new file mode 100755 index 0000000..6cbbb24 --- /dev/null +++ b/Classes/HJMOFileCache.h @@ -0,0 +1,62 @@ +// +// HJFiler.h +// hjlib +// +// Copyright Hunter and Johnson 2009, 2010, 2011 +// HJCache may be used freely in any iOS or Mac application free or commercial. +// May be redistributed as source code only if all the original files are included. +// See http://www.markj.net/hjcache-iphone-image-cache/ + +#import + +/* + Provides file caching for the object manager. Its able to trim its size so it + doesn't grow forever. See also HJBigFileCache. + */ + +@interface HJMOFileCache : NSObject { + + NSString* rootPath; + NSString* loadingPath; + NSString* readyPath; + NSString* countsPath; + + BOOL isCounting; + BOOL isLRU; + long fileCount; + long long byteCount; + + long fileCountLimit; + NSTimeInterval fileAgeLimit; + NSThread* maintenanceThread; +} + +@property long fileCount; +@property long long byteCount; +@property long fileCountLimit; +@property NSTimeInterval fileAgeLimit; +@property (nonatomic, retain) NSThread* maintenanceThread; + +-(HJMOFileCache*)initWithRootPath:(NSString*)root; +-(HJMOFileCache*)initWithRootPath:(NSString*)root + isCounting:(BOOL)isCounting + fileCountLimit:(long)countLimit + fileAgeLimit:(NSTimeInterval)ageLimit; + +-(void)createCacheDirsIfNeeded; + +-(NSString*)filenameForOid:(id)oid; +-(NSString*)readyFilePathForOid:(id)oid; +-(NSString*)loadingFilePathForOid:(id)oid; +-(NSString*)loadingFinishedForOid:(id)oid; +-(void)removeOid:(id)oid; + +-(void) deleteAllFilesInDir:(NSString*)path; +-(void) emptyCache; +-(void) saveCounts; +-(void) loadCounts; +-(void)trimCache; +-(void)trimCacheUsingBackgroundThread; +-(void)trimCacheDir:(NSString*)cachePath; + +@end -- cgit v1.2.3