[Zope-DB] Flushing _v_ attributes (was: Re: Cache Controlled SQL methods (CCSQLMethod))

Dieter Maurer dieter@handshake.de
Sun, 19 Jan 2003 01:21:50 +0100


Dieter Maurer wrote at 2003-1-17 20:23 +0100:
 > ....
 >  > or are there best ways to control ZSQL methods cache that came out later ?
 > I am meanwhile convinced that there is a ZODB method that allows
 > to invalidate all versions of an object in any cache (this would clear
 > the "_v_" variables that hold the cache).
Z SQL Methods maintain their cache in volatile attributes ("_v_" attributes).
These attributes are flushed (in all caches belonging
to this version) when the object is written.

There is a possibility to flush the attributes without writing
the object. It's a bit tricky, though:

  conn= object._p_jar  # the connection, the object belongs to
  db= conn.db()        # the associated database
  db.begin_invalidation()
  db.invalidate(object._p_oid) # invalidates the object in all caches
  db.finish_invalidation()

When you invalidate an object in this way, the object must not be
modified in the current transaction. Otherwise, a "ConflictError"
will result.


Of course, this method gives you not such fine grained
control you get with Cache Controlled Z SQL Methods.


Dieter