[Zope] _v_ for volatile (was Product event when zope restarts
bak (kedai)
kedai@kedai.com.my
Fri, 11 May 2001 09:57:43 +0800
> If you must here is what I would do:
>
> Use two volatile variables to store the mod date and the data like:
>
> _v_mod
> _v_data
>
> Then stat the file when it is accessed and see if its date differs from
> _v_mod (if it has already been accessed). If not, return _v_data.
> Otherwise read the file, return the data and store it into _v_data and
> the mod date in _v_mod.
>
> hth,
---from ZDG-----
The second rule is that all object attributes that begin with _v_ are
"volatile" and are not saved to the database. This means that as long as the
persistent object is in Zope memory cache, volatile attributes can be used.
When the object is deactivated (removed from memory) volatile attributes are
thrown away.
Volatile attributes are useful for data that is good to cache for a while
but can often be thrown away and easily recreated. File connections, cached
calculations, rendered templates, all of these kinds of things are useful
applications of volatile attributes.
---------------------------
so, we may lose _v_mod, _v_data. what if we store these vars to be
nonvolatile. what will that do? is that bad design?
does this fall in the "good to cache for a while but can often be thrown away
and easily recreated" department?
this is something that i don't really understand. when to use _v_, and when
not to.
thanks