pinterest / PINCache

Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deserialize failure fails silently

justin1121 opened this issue · comments

Hello,

I noticed this piece of code fails silently if the deserialization fails on one of the objects. I think it should probably be a fatal and just print out the exception and crash. Spent a while debugging, trying to figure out what was going on.

https://github.com/pinterest/PINCache/blob/master/Source/PINDiskCache.m#L856

@justin1121 The history behind this is we were hearing reports of infrequent crashes. The theory was that somehow the objects on disk were corrupted, perhaps because the app crashed while serializing to disk. In that case, it's better to drop the object as this is a cache, not a guaranteed backing store than crash perhaps over and over again on startup. Seem reasonable?

Perhaps we should add an assert for debugging purposes? I'd be open to that! (Though the PINDiskCacheError is meant to aid in debugging)

Yeah that makes sense. I think doing something like just printing PINDiskCacheError would help. The problem with the one that's there now is that it just prints the error that may come out of removing the file. If there's no error removing the file then it wouldn't print anything.

Check out that pull request. Think it will help with the problems I was having. Thanks!

Awesome, thanks for putting it up!