Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is better caching data with a file or a sqlite database?

I am caching data in an application I am currently writing and was wondering which would be better to use a regular text file or a sqlite database to hold the cached data? Thanks.

EDIT: I am using Zend_Cache so relationships are handled without the need of database. What I am caching is xml strings if saved as regular files can be as big as 60kBs.

like image 575
L Digital Dash Avatar asked Oct 22 '25 04:10

L Digital Dash


2 Answers

Depends on the kind of data you're planning on storing.

If the data is related, and you'd want to retrieve the data based on those relationships...then use SQLite.

If the data is completely unrelated and you're just looking for a way to store a retreive plain text...then use a plain text file. It won't have the added overhead of calling in to SQLite.

If you don't need to persist the data in a file for any reason, and the data lends itself to key/value pair storage...you should look in to something like memcached so you don't have to deal with file IO.

like image 186
Justin Niessner Avatar answered Oct 24 '25 18:10

Justin Niessner


60k is so small you probably wouldn't even bother caching the data, just keep it in memory.

The only reason to write it out to disk if you want to persist the data between sessions. In this case, using text/xml or sqlite wont make much difference.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!