SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend_Cache vs cronjob

    I am working on my bachelor's project and I'm trying to figure out a simple dilemma.

    It's a website of a football club. There is some information that will be fetched from the website of national football association (basically league table and matches history). I'm trying to decide the best way to store this fetched data. I'm thinking about two possibilities:

    1) I will set up a cron job that will run let's say every hour. It will call a script that will fetch the league table and all other data from the website and store them in a flat file.

    2) I will use Zend_Cache object to do the same, except the data will be stored in cached files. The cache will get updated about every hour as well.

    Which is the better approach?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Why can you not use both?
    Have the cron job run a script that uses Zend_Cache?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cache files can get deleted when system reboots and it then the website would have to load all external data and parse it, which would result in a very slow loading time for the unlucky user that visits the website right after the reboot.

  4. #4
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Depending on the situation there isn't much of a difference. I like doing it on request (check cache expire time and rebuild) because there are cases where the data might not get viewed every day. If you have 5 million records, and only 50,000 actively get viewed, you are not bogging the system down with old data rebuilds.

    Just a thought... might not even apply to your situation.
    Adrian Schneider - Web Developer

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Why is your server rebooting?
    A server should very rarely be rebooting.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    zend_cache is just a front-end for things like memcache isn't it ?

    If you plan on using something in memory such as memcache for the zend_cache object, then by all means use the zend_cache object if that's what you're comfortable with. You're probably still going to need the cron job to trigger the script using the zend_cache object on a schedule though.

    If you're just going to use a flatfile back-end for the zend_cache object, you might as well just do your own thing and leave out the loading/instancing of the object though. Unless you plan on moving to something like memcache in the future, then it would be better to go with the zend_cache if that's something you're already comfortable using.

    Then again, maybe I'm missing something. From what I understand though, zend_cache and cron aren't exactly related technologies functionality-wise.

  7. #7
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically the problem with Zend_Cache is that on request, when the cache is dead, it must fetch and parse the data from external server which can result in a slower loading time (or when server reboots). However I made few tests and it seems the process of fetching and parsing the external data is rather fast so that might basically eliminate the problem.

  8. #8
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the rebuild process is rather expensive, then definitely do it at night via cron (which could even internally use Zend_Cache). If not, then just do it at run-time. Both are viable solutions it'll really just come down to your needs, which you have seemed to figure out now.

    You could also call your front-end code through it as well, just incase for some reason the nightly cache is broken.

    Cheers
    Adrian Schneider - Web Developer


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
  •