We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to use the cache in Resultset\Simple

how to use the cache parameter of the class Resultset\Simple? I used as in the example below, but did not work

$cache = $object->getDI ()->get ( 'modelCache' );
Resultset\Simple(null, $object, $object->getReadConnection ()->query ($sql), $cache);

from what I understand, the parameter does not serve anything. the cache must be deployed outside the object.

edited Aug '16

Obviously first you need to store anything to return. What is exactly your query that you can't use phalcon query builder or find method ?

I thought, how is the parameter of a cache object it would cancel the query and inject the cache data. the parameter does not serve anything.

https://github.com/pedro151/cphalcon/blob/master/phalcon/mvc/model/resultset.zep



145.0k
Accepted
answer
edited Aug '16

Well actually you right, not sure for what is it in resultset. Basically in query you are telling to cache it by key.

If you want to store result from raw sql just access modelsCache directly.