문제

I look through the documentation for Zend\Db, and I can not find any answers on how to cache individual queries (Rowset objects).

I know that Zend\Db in ZF2 is much more simplified compared to the ZF1... But still i do not want in my project use Doctrine etc.

And of course I know that my question is little bit too generic...

도움이 되었습니까?

해결책

I think the following bloc-post describes exactly what you ask about: http://samsonasik.wordpress.com/2012/09/27/zend-framework-2-using-zendcache-and-hydratingresultset-to-save-database-resultset/

In short:

  1. instantiate cache storage instance
  2. look in cache
  3. If not in cache
    1. load from db (retrieve instance of ResultSet)
    2. convert ResultSet into serializable data structure (like an array)
    3. write serializable data structure to cache
  4. if in cache you'll get the serializable data structure
  5. handle data (no longer an instance of ResultSet)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top