-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isPresentObjectForKey #43
Comments
+1 |
EDIT: never mind, see below. objectForKey: is functionally equivalent, treat any non-nil return value as "object present". In the end it's just an ordinary NSDictionary lookup (there's no difference between accessing an object and seeing if it exists). https://github.com/tumblr/TMCache/blob/master/TMCache/TMCache.m#L67 |
I do not agree on the above. Currently objectForKey returns the object also. The object may be in the file system which means an expensive disk read and unarchive just for the presence check. Imagine a use case where we want to sync a local TMCache with a remote cache on the server. |
@guptakshi16 you're totally right and I agree, thank you. It should be its own method, and TMDiskCache for its part should just check the presence of the file on disk. Until that's added I think you could use TMDiskCache::fileURLForKey:block: and pass a block that manually checks for the file with NSURL::checkResourceIsReachableAndReturnError: followed immediately by a call to TMMemoryCache::objectForKey:block: |
This pull request might add the functionality that @guptakshi16 is asking for: #29 |
A api to check if the object is present in the cache will be a great enhancement in this project.
I was thinking of adding a bloom filter to add this functionality. Need feedback if this is already present in some other way.
The text was updated successfully, but these errors were encountered: