Data caching - files or a database?
Posted: Thu Oct 30, 2008 1:56 pm
Hi there,
I've been lately trying to solve this puzzle. Which one is faster, caching in files or in a database?
Right now I have a file based caching.
That compared to with no caching
is always 20-30 times faster for same queries. So, in other words, caching into files seem to be faster than no caching. Maybe this applies to my local PC only? But after having a look at phpBB and other scripts, they also cache in files. They simple cache the SQL result set in a file.
I was now thinking, what if I cache into the database? I'm not caching SQL results in a db, but I would cache other vital information. I could create a PHP file containing lets say an array of 500 rows OR I could insert them to a database. But which one is faster to load? Loading the data from this arrayed file or from a database?
I've been lately trying to solve this puzzle. Which one is faster, caching in files or in a database?
Right now I have a file based caching.
Code: Select all
$db -> exec(3600*24); // time to live aka expirationCode: Select all
$db -> exec(0); // false/0 = no cachingI was now thinking, what if I cache into the database? I'm not caching SQL results in a db, but I would cache other vital information. I could create a PHP file containing lets say an array of 500 rows OR I could insert them to a database. But which one is faster to load? Loading the data from this arrayed file or from a database?