On Thu, Jun 27, 2013 at 12:58 PM, Arne Dirks <arne.di...@iathh.de> wrote:
> On 06/27/2013 08:56 AM, Mandeep Sandhu wrote: > > get(key): > > * Open the file in Read-Only mode. > > * Parse the data and prepare a QMap of the key-value pairs. > > * Close the file > > * Return the value for the key > > > > set(key, value): > > * Open the file in Read-Only mode. > > * Parse the data and prepare a QMap of the key-value pairs. > > * Close the file > > * Open the file in Write-Only & Truncate mode > > * Insert the new key-value in the map > > * Write the map > > * Close the file > > Is there a reason why you read the file every time you get/set > something? Couldn't you read the file once during application startup, > Yes, there's a reason. The data fetched by the app is via a _relatively_ expensive network handshake with a remote service. The data returned is not much and hence I thought it better to write it the moment i receive it. There's a possibility that the app might be closed/crash due to some external factors and if I have it in memory (as a map) then I'd have to the network op all over again. -mandeep > store the data in a map and only write it out again when your > application terminates, provided anything has changed at all? > arne > > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest