title: Kohana 3 - How to use memcached for cache query results?
body: <p>I'm working in a large project using Kohana 3 framework, actually I need to improve it adding a cache system to reduce the number of MySQL connections.</p>
  
  <p>I'm thinking in develop a basic (but general) module to generate a full query results caching but separately manage the table query results into different groups.</p>
  
  <p>Pex:</p>
  
  <p>cache groups: users, roles, roles_users, etc.</p>
  
  <p>Each group contains all the query results from the correspondant table. So, if I want to get values from 'users', the cache system would automatically add the result to the cache system, but if I update the 'users' table all the keys in 'users' group would be deleted. I know, it's not so smart but it's fast and safe (the system also generate user lists, and the results may be correct).</p>
  
  <p>Then, my question is: ¿Where an how can I make the "injection" of my code in the application tree?</p>
  
  <p>I need, firstly (to generate a hash key) the full query (for a certain table -used as group-), and the result of that query to store. And, when another hash (in the that group) is the same as stored one, the value must be getted from memcached.</p>
  
  <p>So, I need: the table name, the query and the result... I think it's possible extending the Database class, implementing the cache in the execute() method, but I can't find it!</p>
  
  <p>I'm in the correct way? Where the execute() method is?</p>