risoknop — 2010-02-08T18:38:42-05:00 — #1
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?
logic_earth — 2010-02-08T20:21:29-05:00 — #2
Why can you not use both?
Have the cron job run a script that uses Zend_Cache?
risoknop — 2010-02-08T20:46:11-05:00 — #3
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.
siradrian — 2010-02-08T20:54:59-05:00 — #4
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.
logic_earth — 2010-02-08T20:55:51-05:00 — #5
Why is your server rebooting?
A server should very rarely be rebooting.
joebert — 2010-02-08T21:22:14-05:00 — #6
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.
risoknop — 2010-02-08T22:44:31-05:00 — #7
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.
siradrian — 2010-02-08T23:39:30-05:00 — #8
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.