Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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



114.7k
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.