Re: [VOTE] Weak References
| From: | Ferenc Kovacs | Date: | Wed, 03 Aug 2011 22:41:07 +0000 |
| Subject: | Re: [VOTE] Weak References | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-54329@lists.php.net to get a copy of this message | ||
On Thu, Aug 4, 2011 at 12:35 AM, Jonathan Bond-Caron <jbondc@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