Re: Odd NSCache Eviction Behaviour
Re: Odd NSCache Eviction Behaviour
- Subject: Re: Odd NSCache Eviction Behaviour
- From: Graham Cox <email@hidden>
- Date: Tue, 05 Apr 2011 22:16:39 +1000
On 05/04/2011, at 7:01 PM, Dalmazio Brisinda wrote:
> Pity. NSCache looked so promising
You could roll your own cache class that has the same interface but uses a LRU algorithm internally. Then if NSCache is updated it would be a drop-in replacement. The only drawback with it at present (which might be considered rather major) is that there's no straightforward way to hook your own cache objects into the runtime such that it would automatically cause eviction when memory pressure is tight. On iOS I believe there is a hook for responding to low memory, but on Mac OS there isn't, unfortunately. The best you can do is to set some sort of high water mark limit that evicts the LRU objects whenever the cache is accessed. Doing that is obviously pretty straightforward.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden