PDA

View Full Version : Storing data in a tmpfile before querying a database


m1a2x3x7
08-23-2011, 05:01 PM
I'm trying to find the correct solution for my application. I'm wondering if creating a tmpfile is correct.

I'm collecting data (impressions and clicks) for items on a page. I don't want to query the database every time to page loads because there will be hundreds of impressions for every page load.

My thought was to store all the impressions in a tmp file, then every hour run a task or cron job from the server that then queries the database and distorys the tmpfile.

Am I going about this the right way? Or should I try something different?

Thanks.

-M

davidj
08-30-2011, 01:12 PM
Why not store in a $_SESSION

m1a2x3x7
08-30-2011, 01:52 PM
Hey David,

I'm wanting to store thousands of impressions from different users and only query the database onces every hour or so. I'm not seeing how a session would be of use in this situation since a session would be unique for a single user.

davidj
08-30-2011, 02:10 PM
I would probably use the database directly. I am sure it can handle it.

If you want to store to a temp file then I have a script knocking about somewhere I can send you

m1a2x3x7
08-30-2011, 04:00 PM
That's OK. I can write something up no problem. I just wanted to if there was another way to go about it.