views:

92

answers:

2

I'd like to perform the following:

1) Open a dataset (using TMSQuery, SDAC DevArt component)

2) caching the content to disk (imagine a list of cutsomers)

3) the next time I need to Open the dataset I will first populate it with cached data, then I will just Refresh it by calling TMSQuery.RefreshQuick method.

In this way I plan to obtain a substantial improvement in speed, because I don't need to retrieve records that I already retrieved in previous application runs.

How can I obtain this caching? I have many datamodules with TMSQuery, so somehow I would like to have a global routine that checks that everytime I try to Open a TMSQuery, if that query is somehow tagged i will try to restore from cache, call RefreshQuick, in case this fails I will call Open.

Can you please suggest?

(I use Delphi 2009 and SDAC 4.80)

+1  A: 

You can do 2 things:

  1. Make descendant of the TMSQuery component and override the Open function (you search all you datamodule .dfm and .pas files with TMSQuery and replace with TCachedTMSQuery)
  2. Detour/hook the TMSQuery.Open (runtime patching)
André
+2  A: 

you can use the TClientDataSet and TDataSetProvider components for this, connecting the components in this way.

TMSQuery->TDataSetProvider->TClientDataSet

The TClientDataSet is a very good alternative to persist and retrieve data from an disk.

see these links for more info about the ClientDataset

RRUZ