Tuesday, July 22, 2014

Re: Caching-Strategy for Model-Data in Cake3

I often create plenty small custom finders I can combine. Also I find myself creating very specialized finders which sole responsibility is to combine multiple others.
for example in an application of mine I have a findForNewsletter() which composes findActive(), findSubscribed(), findForLocation() and a few others. Those specialized
finders I use in bigger routines like a controller or a shell.


On Tuesday, July 22, 2014 2:13:16 AM UTC+2, Sven wrote:
Hi all!

I am wondering what your opinions are about the best way to tackle caching within Cake 3 within the model-layer.

When writing custom finders for your tables you can have 3 approaches:
  1. Write small, easy to read, understand-, maintain- and testable finder-methods which you then might chain
  2. Write somewhat bigger custom find-methods which allow for more dedicated caching and a thinner model-layer
  3. Combine both approaches (i.e: combine the small bits to the big one)
Lets say you are writing a method for twitter that shows the very last tweet for a given user and you know that this will be often used.

You could then have something like
  • findPublished, findLatest, findForUser
or
  • findLatestPublishedForUser
in your Tweet-Table-Class.

What would you do? I'm also asking to check if I understood the purpose of the Query-Builder correctly. Having the ability to combine different find-methods seems great!

I hope it's okay to ask those questions here. I think that this question might not have been problem-orientated enough for SO.

Best regards
Sven

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: