TumblrArchive / TMCache

Fast parallel object cache for iOS and OS X.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"byteCount" get the wrong value after caching multiple times on the same key

vietstone-ng opened this issue · comments

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.

I opened an issue for this (with the fix) a while back, #42

Guess I should do a PR?

wow, why hasn't that fix been added after a long time? :D

Well, I don't think there's been a PR yet?

Fixed: #82