[Qt-interest] Will QSettings be cached?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Tue Dec 15 09:18:25 CET 2009
donglongchao wrote on Tuesday, December 15, 2009 8:58 AM:
> ...
> If yes,I think I can create a QSettings object as a global variable
> and use it directly and quickly(because they are in the memory,not
> hard disk) anywhere in my app if I want to get/set some value
Why do you worry about the performance of a simple class such as QSettings? Usually you do store small amounts of data, such as a few strings, ints and booleans. Or what is your intention with QSettings?
Even if QSettings would access the disk each time you requested an integer that would not be so bad, because modern file systems have a cache of their own.
> ,even in
> different threads.Is it the right way?Do I need to use QMutex to
> protect it?
"Use the docs, Luke, use the docs!":
http://qt.nokia.com/doc/4.6/qsettings.html#accessing-settings-from-multiple-threads-or-processes-simultaneously -
> AFAIK,the similar thing(I forgot the exact name of it)
> used to save/read configure informations in GTK+ will be cached. If
> not,do I have to write/read them from hard disk every time I want to
> use it?Is there a better and faster way?
Again, do you have concrete performance issues with that? How often do you need to read them? How much data are we talking about? Is there a network involved maybe (latency!)?
Off course you could always look into the Qt source code yourself, but I strongly assume that this is platform-dependent and is not to be exposed to the user. On Windows settings are stored in the registry (or *.ini files), whereas on other platforms *.ini files are used etc. - depending on the implementation settings could be read each time or indeed cached by QSettings (I am totally shooting into the blue here though) - but don't rely on that!
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list