Jump to content

What is best format to write(and update) cache files?


physaux

Recommended Posts

Hey guys, I am trying to get my cache system up and running. I don't want to query my database evertime a user wants something that is generic, and only update the "cache" of it when it changes.

 

I plan on writing it to a file, but I need some advice...

- each input has 5 fields, so what would be the best way to seperate them in a file? I know I would just use explode to read it back into an array, but I need the "dividing string" to be something that would not occure in the input. Such as

[|]

. But there is always a chance that might appear.

 

so question A) What is the best way to format my file. (maybe i should "escape" my explode text with preg replace?)

 

question B) What would be the best way to "update" the file, without having to rewrite it.

 

Ex if I want my file to hold the 5 most recent values, When a new one appears, I have to kick out the oldest. How could I efficiently do this?

 

thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.