If I do a clearCaches() method that clears _v_ attributes on the object, how can I make sure it will clear these attributes in all the Zope connections that may have a cached copy of the object ? Or do you mean that clearCaches() should do the self._p_changed=1 ? Pascal -----Message d'origine----- De : zope-bounces@zope.org [mailto:zope-bounces@zope.org]De la part de Andrew Milton Envoyé : mercredi 19 janvier 2005 11:44 À : Pascal Peregrina Cc : 'zope@zope.org' Objet : Re: [Zope] Clearing _v_ attributes +-------[ Pascal Peregrina ]---------------------- | Hi, | | To clear some data caching I have made using _v_ attributes on one | particular object, I would need a way to programmatically clear its _v_ | attributes. | | As far as I understand, _v_ attributes are set per ZODB connection. | And they are cleared when the object is, for some reason, reloaded from the | ZODB to the connection cache. | | As I use the current configuration : | + ZEO | + 1 Zope instance with RW connections to ZEO | + several Zope instances with RO connections to ZEO | | I was wondering if, setting self._p_changed=1 on the object from the Zope RW | would work. No... Why not just add a clearCaches() method that Does The Right Thing(tm) and call that? -- Andrew Milton akm@theinternet.com.au _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************
+-------[ Pascal Peregrina ]---------------------- | If I do a clearCaches() method that clears _v_ attributes on the object, how | can I make sure it will clear these attributes in all the Zope connections | that may have a cached copy of the object ? Basically you can't. Although if a thread doesn't wake up for 10 mins (with your object), then odds are it'll get thrown out and brought back in again without the _v_ attributes set, so it's probably a moot point. You would have to grab each ZODB connection present, grab your object and call the method.. That's just getting in voodoo you probably don't actually need. The best you could do would be to set a flag / timestamp. Any object that woke up would have to check that timestamp and work out whether to flush at that point or not. | Or do you mean that clearCaches() should do the self._p_changed=1 ? _p_changed = 1 won't flush your _v_ attributes. -- Andrew Milton akm@theinternet.com.au
On Wednesday 19 January 2005 11:51, Andrew Milton wrote:
+-------[ Pascal Peregrina ]---------------------- | If I do a clearCaches() method that clears _v_ attributes on the object, how | can I make sure it will clear these attributes in all the Zope connections | that may have a cached copy of the object ?
Basically you can't.
There is one very obvious way.... change a non-_v_ attribute of the object and commit it. Every other connection with an instance of that object in memory will lose the _v_ attribute at its next transaction boundary. -- Toby Dickenson
+-------[ Toby Dickenson ]---------------------- | On Wednesday 19 January 2005 11:51, Andrew Milton wrote: | > +-------[ Pascal Peregrina ]---------------------- | > | If I do a clearCaches() method that clears _v_ attributes on the object, | how | > | can I make sure it will clear these attributes in all the Zope connections | > | that may have a cached copy of the object ? | > | > Basically you can't. | | There is one very obvious way.... change a non-_v_ attribute of the object and | commit it. Every other connection with an instance of that object in memory | will lose the _v_ attribute at its next transaction boundary. And your ZODB grows everytime you want to flush the cache... -- Andrew Milton akm@theinternet.com.au
Andrew Milton wrote:
+-------[ Toby Dickenson ]---------------------- | On Wednesday 19 January 2005 11:51, Andrew Milton wrote: | > +-------[ Pascal Peregrina ]---------------------- | > | If I do a clearCaches() method that clears _v_ attributes on the object, | how | > | can I make sure it will clear these attributes in all the Zope connections | > | that may have a cached copy of the object ? | > | > Basically you can't. | | There is one very obvious way.... change a non-_v_ attribute of the object and | commit it. Every other connection with an instance of that object in memory | will lose the _v_ attribute at its next transaction boundary.
And your ZODB grows everytime you want to flush the cache...
Could you please further detail the reason of the above (or provide pointers on this?) Regards Marco
participants (4)
-
Andrew Milton -
Marco Bizzarri -
Pascal Peregrina -
Toby Dickenson