steipete / SDURLCache

URLCache subclass with on-disk cache support on iPhone/iPad. Forked for speed!
http://twitter.com/steipete
MIT License
598 stars 102 forks source link

Flush just in-memory cache? #8

Open sixten opened 12 years ago

sixten commented 12 years ago

The NSURLCache class provides a method by which one can dump the entire contents of the cache (-removeAllCachedResponses). What doesn't seem to be available, and would seem to be useful on iOS, would be a way to clear the contents of the in-memory cache, but not drop the items on disk. (The scenario being responding to a memory warning, where you need to free up storage, but clearing out disk space doesn't have any value.)

Seems like the implementation might be as simple as:

- (void)removeAllCachedResponsesInMemory {
    [super removeAllCachedResponses];
}

(With the obvious down side that if the Foundation implementation ever gains disk caching, this would be bad.)

steipete commented 12 years ago

Looks good. Can you make it a pull request?