[html-formfu] Speed of processing

Octavian Râşniţă orasnita at gmail.com
Tue Nov 3 16:28:44 GMT 2009


From: "Ronald J Kimball" <rkimball+formfu at pangeamedia.com>
> A user accesses the form. This creates a cached version of the form. A 
> second user gets the form from the cache and adds data to it. Without 
> cloning the form, the data would be stored by reference in the cache or 
> something like that, and the other users would also get it.
> I just thought that once the user gets the form from the cache, no matter 
> what it does to that form, his changes can't propagate back to the cache 
> so no cloning was needed... I hope I understood correctly.
>

That depends on how your cache is implemented.  If you're caching the
form object in memcached, for example, then you have to freeze and thaw,
and every time you fetch from the cache you're automatically creating a
new object.  If you're caching the form object by simply keeping a
reference to it in the current process, then you have one object that
you're reusing repeatedly.  The cache in this case is the latter, so
that's why the cloning is necessary.
Ronald

Oh yes, finally I understood that. I was thinking to a cache type like one 
that uses Cache::FileCache and I thought that caches like these don't allow 
storing references and objects but only data structures. This is why I 
didn't understand why cloning is needed.

Of course, if an object is stored in the memory and more users use it, the 
data is sent by reference and everyone gets it, but beeing afraid of memory 
leaks... I always prefered a cache that store a serialized data. (Which in 
case of HTML::FormFu might not be possible)

Octavian









More information about the HTML-FormFu mailing list