"byteCount" get the wrong value after caching multiple times on the same key
vietstone-ng opened this issue · comments
Viet Nguyen Tran commented
A simple example:
self.myDiskCache = [[TMDiskCache alloc] initWithName:@"myDiskCache"];
UIImage *myImg = .....; // 5MB
// call cache multiple times
dispatch_async(self.mySerialQueue, ^{
for (int i=0; i<10; i++) {
[self.myDiskCache setObject:myImg forKey:@"myKey" block:^(TMDiskCache *cache, NSString *key, id<NSCoding> object, NSURL *fileURL) {
NSLog(@"%f MB", cache.byteCount/pow(2., 20.));
}];
}
});
The expectation outputs is "5 MB" for all.
But the chain is 5 MB, 10 MB, ... 50 MB.
Sudeep Sidhu commented
I opened an issue for this (with the fix) a while back, #42
Guess I should do a PR?
Viet Nguyen Tran commented
wow, why hasn't that fix been added after a long time? :D
Samuel Giddins commented
Well, I don't think there's been a PR yet?
Bryan Irace commented
Fixed: #82