Welcome Guest, Not a member yet? Register   Sign In
Cache Model interactions
#7

(This post was last modified: 01-15-2018, 04:38 PM by natanfelles. Edit Reason: typo )

[Image: p2CybXB.png]
As this example image, the following process can occurs when get a post:
  • Get the Post(s) and save it to the cache
  • Can have an afterFind Event and return the author on the fly
  • Can return the the X newest comments
  • In the Comments model can return an associative array with child comments
Then the $posts->find(5) will return:


PHP Code:
[
 
   'id'        => '5',
 
   'author_id' => '2',
 
   'title'   => '...',
 
   'content'   => '...',
 
   'author'    => [/* Author fields */ ],
 
   'comments'  => [
 
       [/* comment x */],
 
       [/* comment y */],
 
   ],
 
  'created_at' => '...',
 
  'deleted_at' => '...',




First find some queries will put every item in the cache. In the next, it get from the cache and update with a query result if necessary.

I do not found an way to manage results using the query builder before the finds, like "select(['id'])->find(5)" yet. Then the best to do, I think, is put all the table fields in the cache. Turning it "alive".

Inspiration:

- http://highscalability.com/blog/2010/5/1...-page.html
Reply


Messages In This Thread
Cache Model interactions - by natanfelles - 01-02-2018, 06:42 PM
RE: Cache Model interactions - by kilishan - 01-02-2018, 08:37 PM
RE: Cache Model interactions - by natanfelles - 01-02-2018, 10:04 PM
RE: Cache Model interactions - by kilishan - 01-02-2018, 10:12 PM
RE: Cache Model interactions - by puschie - 01-03-2018, 04:15 AM
RE: Cache Model interactions - by natanfelles - 01-15-2018, 05:04 AM
RE: Cache Model interactions - by natanfelles - 01-15-2018, 06:31 AM
RE: Cache Model interactions - by natanfelles - 01-23-2018, 06:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB