TumblrArchive / TMCache

Fast parallel object cache for iOS and OS X.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[TMCache sharedCache].diskCache.byteCount returns 0

fvisticot opened this issue · comments

I fill the cache with some images, I restart the app and I call the following code:

NSLog(@"%lu", (unsigned long)[TMCache sharedCache].diskCache.byteCount);

The logs is displaying 0 !!!

If I'm correct this method should return the number of bytes used on the disk used to save my images (35)...and it should not be 0...

You're right, it should tell you the total disk use. Are the images definitely coming from the cache? (Maybe it really is empty?)

Any other code or clues you could share?

commented

it a time capsule 2T

On Fri, Apr 26, 2013 at 7:10 PM, Justin Ouellette
notifications@github.comwrote:

You're right, it should tell you the total disk use. Are the images
definitely coming from the cache? (Maybe it really is empty?)

Any other code or clues you could share?


Reply to this email directly or view it on GitHubhttps://github.com//issues/19#issuecomment-17108613
.

fvisticot, can you try this for me in place of your log statement?

dispatch_async([TMDiskCache sharedQueue], ^{
    NSLog(@"byte count: %d", [[[TMCache sharedCache] diskCache] byteCount]);
});

It works fine with this code:
dispatch_async([TMDiskCache sharedQueue], ^{
NSLog(@"byte count: %d", [[[TMCache sharedCache] diskCache] byteCount]);
});

BUT it is really not user friendly :(

Fred

On Sat, Apr 27, 2013 at 4:19 AM, Justin Ouellette
notifications@github.comwrote:

fvisticot, can you try this for me in place of your log statement?

dispatch_async([TMDiskCache sharedQueue], ^{
NSLog(@"byte count: %d", [[[TMCache sharedCache] diskCache] byteCount]);
});


Reply to this email directly or view it on GitHubhttps://github.com//issues/19#issuecomment-17108749
.

Agreed, I'm going to think of a way to expose this without deadlocking the queue. Thank you!

I added a property on TMCache called diskByteCount that basically does this synchronously. byteCount can continue to be accessed safely within blocks run the shared disk cache queue. Look for it in 1.0.3 later this afternoon.