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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With