0

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)

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • 1
    When refreshing your data, you have to compare it to the values in the database, so you still have to query all data. How does this improve speed? You have a DateModified field or something? – The_Fox Oct 07 '10 at 10:18
  • I plan to use TMSQuery.RegreshQuick method. – UnDiUdin Oct 07 '10 at 11:43

2 Answers2

3

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
  • 134,889
  • 20
  • 356
  • 483
1

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é
  • 8,920
  • 1
  • 24
  • 24