in reply to Storable for user preferences
I would avoid Storable simply because it depends on the Perl version and the perl configuration. That would be acceptable for short-term, temporary storage (say up to a few days), but not for long-term storage. Sooner or later, you will update perl, and that may get you in trouble with Storable. Another problem is that Storabe uses a binary format, which makes it harder to debug.
The common text-based formats JSON, XML, INI, and YAML have specs that do not depend on Perl at all. Upgrading perl won't be a problem. And of course, those formats are more or less human readable.
Some relational databases have added support for data in JSON and/or XML format, so accessing JSON/XML data from within SQL is possible and should be quite efficient. I assume that you need the set of user preferencs only in Perl, not in SQL. So simply serializing your user preferences to a JSON or XML string and deserializing them back should work even without JSON/XML support from the database. In general, you would load the user preferences on login and keep them for the entire session. You write them only if the user changes some user preferences. Parsing a little bit of JSON or XML at login should not hurt much. And as a nice extra, the JSON / XML containing the user preferences is just a bit of text for the database. Storing and retrieving text works with every relational database, it keeps your code independant from the actual database.
Alexander
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Storable for user preferences
by Bod (Parson) on Oct 01, 2023 at 10:55 UTC |