On Thu, Aug 4, 2011 at 12:35 AM, Jonathan Bond-Caron <jbo...@openmv.com> wrote:
> On Wed Aug 3 05:16 PM, Lester Caine wrote:
>> Jan Dolecek wrote:
>> > I was waiting for this for a while! I wrote a blog post how to get
>> > best benefits from weak references:
>> > http://blog.juzna.cz/2011/08/weak-references-in-php/
>> > Perhaps this will help showing people what are they good for.
>>
>
> Or you can use various caching algorithms (LRU, MRU, ..) to reduce memory 
> usage:
>
> $this->cache = new ArrayLimit(2);
> $this->cache->add(new LargeObject('A'));
> $this->cache->add(new LargeObject('B'));
> $this->cache->add(new LargeObject('C'));
> $this->cache->count(); // 2
>
> To solve a "caching problem" weak references aren't very helpful since 
> there's no way to know when or which objects will be garbage collected 
> (non-deterministic).
>

almost every caching mechanism is non-deterministic, so obviously that
isn't a problem for a cache.
a cache is a cache, because you can regenerate its content anytime, if needed.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to