SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MVC Best place to put the caching

    Hi.
    What's the best and suitable place to put the caching, should it go into the viewer, or the model, or the controller ?

    Thanks in advance.

    Bye

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It would depend on what you're caching, no other entity should be responsible for the functionality of another.

    IMO, of course.

    PHP Code:
    <?php
    $model 
    = new CachingModel();
    $view = new CachingView();
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Zealot Amenthes's Avatar
    Join Date
    Oct 2006
    Location
    Bucharest, Romania
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There was a similar thread not long ago:

    http://www.sitepoint.com/forums/showthread.php?t=637597
    I'm under construction | http://igstan.ro/

  4. #4
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Ireland
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is something AOP is great for. Unfortunately, I believe (could be wrong) the various PHP AOP implementations leave a lot to be desired.

  5. #5
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    It would depend on what you're caching, no other entity should be responsible for the functionality of another.

    IMO, of course.

    PHP Code:
    <?php
    $model 
    = new CachingModel();
    $view = new CachingView();
    ?>
    I'm caching a result (object) from a query.
    PHP Code:
    $model = new CachingModel(); 
    If you mean put it in the controller I disagree
    to the controller doesn't mind if data are cached or not
    IMHO

    I took a look to Amenthes link

    so I agree with Mastodont
    Quote Originally Posted by Mastodont View Post
    Should the caching be done in the view?
    It depends on what do you want to cache.
    - db query -> cache in model
    - part of page -> cache in view or model
    - whole page -> cache in view

    @Ryan Wray interesting

    Bye.

  6. #6
    Non-Member
    Join Date
    Sep 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are we talking caching in a folder or memory?

  7. #7
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    folder


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •