[Solar-talk] Problem with APC + objects created inside views / view helpers
Rodrigo Moraes
rodrigo.moraes at gmail.com
Sat Apr 21 05:26:39 PDT 2007
Hi,
I use APC, and yesterday I've noticed a strange thing using it. When a
model object is created inside a view helper and it is is not cached
yet (Solar_Sql_Model_Catalog data), PDO throws an exception:
array ( 'exception' => PDOException::__set_state(array( 'message' =>
'You cannot serialize or unserialize PDO instances', [...]
This happens with objects created using factory, or dependencies
created in the view part. Inside a helper, for example:
$res = Solar::registry('model_poll')->fetchAll();
If 'model_poll' is a dependency for a never called and thus not cached
model data, the exception is thrown. If it is a registered object
(registered in the controller), no problem happens. APC doesn't deal
very well with models created in the view part of the app.
(I use some helpers as "page modules", created independently of the
controller, and so models and views are called there)
A workaround was to register the model objects in the controller, and
not their dependencies. So in the view it is already built and well
cached.
I like APC, and I think the latest versions work pretty well with
Solar, and all previous problems with class loading etc have been
solved. But I would like to hear recommendations, if you use other
cache systems.
But I'm really curious to know the mechanism that confuses APC. Why
models first created inside a view helper make it work badly? Any
ideas?
rodrigo
More information about the solar-talk
mailing list