SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    858
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Efficient to call file_get_contents over and over again?

    I store all outgoing emails in a database. A cron wakes up every 30 minutes to send out the next batch of emails. Up until now each of the 15 different types of email were all plain text, but I plan on moving to html based templates. Would it be more efficient to call all 15 email templates at once, even though not all of them may get used in a particular run? Or would it be more efficient to call the templates as needed in my DO WHILE loop even if that means calling certain templates over and over? Does this make sense?

    $importedBody = file_get_contents('emailTemplates/hero.html');


    Thanks!
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would pull them one at a time then cache them for later use.
    coming soon sitejuju.com my new development portfolio

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    As stated somewhat ambiguously by jgetner, the answer is 'neither'.
    Assuming that the templates in question are not excessively large, pull them as-needed and store them in an array for reuse.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


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
  •