vendredi 4 mars 2016

What Design pattern for keeping data partly in ROM (SQL) and Partly in RAM (memory)?

I am projecting an app with C++ and Qt. I have frequently needed data in Class Object and rarely neded data in Class ObjectExtended. Every Object is associated with ObjectExtended.

Example:

 Class Object 
 {
     string importantData; //we need that very often
     int id;
 }

 Class ObjectExtended
 {
     date dateCreated; //meta info, we need this rarely
     int assosiatedObjectId; //to know to which Object this extended data relates
 }

I have the list of objects list and list.

What I want is to keep list in RAM (memory) and keep list in ROM (local storage, for example SQL). It is needed to save memory. I already keep data in SQL to save application state and data.

The problem which I may face is that my data can change and I will have to rewrite tonns of code if I separate data for Object and ObjectExtended.

Is there some design pattern which suits the best for my issue?

Aucun commentaire:

Enregistrer un commentaire