Return-Path: Mailing-List: contact python-dev-help@httpd.apache.org; run by ezmlm Delivered-To: mailing list python-dev@httpd.apache.org Received: (qmail 42963 invoked from network); 26 Jun 2003 23:58:56 -0000 Received: from 205-158-62-67.outblaze.com (HELO spf13.us4.outblaze.com) (205.158.62.67) by daedalus.apache.org with SMTP; 26 Jun 2003 23:58:56 -0000 Received: from 205-158-62-146.outblaze.com (205-158-62-146.outblaze.com [205.158.62.146]) by spf13.us4.outblaze.com (Postfix) with QMQP id 856161889D32 for ; Thu, 26 Jun 2003 23:59:02 +0000 (GMT) Received: (qmail 17316 invoked from network); 26 Jun 2003 23:51:48 -0000 Received: from unknown (HELO ws3-5.us4.outblaze.com) (205.158.62.95) by 205-158-62-146.outblaze.com with SMTP; 26 Jun 2003 23:51:48 -0000 Received: (qmail 19766 invoked by uid 1001); 26 Jun 2003 23:58:25 -0000 Message-ID: <20030626235825.19765.qmail@email.com> Content-Type: text/plain; charset="ISO-8859-1; format=flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Mailer: MIME-tools 5.41 (Entity 5.404) Received: from [65.96.181.124] by ws3-5.us4.outblaze.com with http for jack_diederich@email.com; Thu, 26 Jun 2003 18:58:25 -0500 From: "Jack Diederich" To: python-dev@httpd.apache.org Cc: mod_python@modpython.org Date: Thu, 26 Jun 2003 18:58:25 -0500 Subject: Re: [mod_python] Using shared memory to do global persistence X-Originating-Ip: 65.96.181.124 X-Originating-Server: ws3-5.us4.outblaze.com X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N From: VanL > I think that the nicest solution (in terms of API, at least) would be to > have an explicit namespace that is instantiated when mod_python is first > loaded. Applications could then access this shared namespace by > importing it; anything declared in the namespace would be automatically > shared. > > For example. > from mod_python import apache.shared as shared > > shared.myvar = 'something here' > In the future setting variables in other module spaces may be outlawed in python. Treating modules like classes/objects is also strongly discouraged. I think your use of dicts is dead on, something like: def do_calc(): cache = mod_python.shared if ('foo' not in cache): cache['foo'] = 'bar' return cache['foo'] As I mentioned during the long thread on what frameworks should do, we could add two dicts to mod_python, mod_python.page_cache # caching dict created per-request mod_python.perm_cache # cache valid accross all processes for ever perm_cache could actually lie and just keep the last X least recently used entries, but the main idea is that it is long lasting and valid accross all processes. An intermediate mod_python.proc_cache that is similarly 'permenent' for the life of the process, but only caches values locally to the current process might be useful in a pure-forking server because it doesn't have to worry about locking. If you are threading you have to do locking anyway, so perm_cache is more useful. -jack -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup