Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54329 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54161 invoked from network); 3 Aug 2011 22:41:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2011 22:41:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-gx0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:37930] helo=mail-gx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/43-34160-78EC93E4 for ; Wed, 03 Aug 2011 18:41:11 -0400 Received: by gxk27 with SMTP id 27so850437gxk.29 for ; Wed, 03 Aug 2011 15:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=yRU4IvBdYrSb805ZOGpuXGLIuDBe071ra6zFwr2pmjY=; b=T3W67hNyU4sWx/RDBTNn3TSFpMYCyhz22VYIDumfB5ZuZgfxjfACEDvp7lqa/FkYni HiVEC00w4YdK9Qec8djoBBJdNYgrO9RdwKVDjKQXx8Rg6bJi6So5E2sagwJ1u02EJsZO Rk4JPsgV/IYcYHXnm4cUMNln+3bBTJvKTt/ao= MIME-Version: 1.0 Received: by 10.236.184.169 with SMTP id s29mr67107yhm.68.1312411267662; Wed, 03 Aug 2011 15:41:07 -0700 (PDT) Received: by 10.147.82.17 with HTTP; Wed, 3 Aug 2011 15:41:07 -0700 (PDT) In-Reply-To: <002101cc522d$99aed6c0$cd0c8440$@com> References: <4E3898B0.40809@sugarcrm.com> <4E38EC0C.9080304@lerdorf.com> <4E38FA2E.4030605@lsces.co.uk> <4E38FC67.9090200@toolpark.com> <4E39BA93.30601@lsces.co.uk> <002101cc522d$99aed6c0$cd0c8440$@com> Date: Thu, 4 Aug 2011 00:41:07 +0200 Message-ID: To: Jonathan Bond-Caron Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Weak References From: tyra3l@gmail.com (Ferenc Kovacs) On Thu, Aug 4, 2011 at 12:35 AM, Jonathan Bond-Caron wr= ote: > 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 =3D 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 th= ere's no way to know when or which objects will be garbage collected (non-d= eterministic). > 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 need= ed. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu