Skip to content

Commit

Permalink
Merge pull request #12 from jpm/master
Browse files Browse the repository at this point in the history
Fixed small issue where expired entries wouldn't be removed from the dictionary file, resulting in very large files in the long run.
  • Loading branch information
shnhrrsn committed Apr 19, 2012
2 parents 018a217 + c3b7a97 commit a646caa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions EGOCache.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,12 +96,17 @@ - (id)init {
attributes:nil attributes:nil
error:NULL]; error:NULL];


NSMutableArray *removeList = [NSMutableArray array];
for(NSString* key in cacheDictionary) { for(NSString* key in cacheDictionary) {
NSDate* date = [cacheDictionary objectForKey:key]; NSDate* date = [cacheDictionary objectForKey:key];
if([[[NSDate date] earlierDate:date] isEqualToDate:date]) { if([[[NSDate date] earlierDate:date] isEqualToDate:date]) {
[removeList addObject:key];
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(key) error:NULL]; [[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(key) error:NULL];
} }
} }
if ([removeList count] > 0) {
[cacheDictionary removeObjectsForKeys:removeList];
}
} }


return self; return self;
Expand Down

0 comments on commit a646caa

Please sign in to comment.