Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3279024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:32:46+00:00 2026-05-17T19:32:46+00:00

For a dataset which takes a very long time to open (it is a

  • 0

For a dataset which takes a very long time to open (it is a stored procedure), I would like to implement some kind of caching on the Datasnap server.

So if this dataset is loaded the first time and transferred to the client (TClientDataSet), it should not be closed and reopened for the following requests unless the server restarts or a “reload” procedure on the server is called.

So after the first open, every new client would only receive a copy (clone) of the dataset without refreshing / reloading the server side dataset.

For a simple implementation of this dataset ‘cache’ the Datasnap server datamodule must not be created per session (because for each new session, the server side dataset would be closed until the client sends the request to open the DatasetProvider). Maybe I can find a solution to clone the dataset also for session datamodules but my basic question is:

Is there a way to override methods in the DatasetProvider so that the client can still open, but not close the server-side dataset?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:32:46+00:00Added an answer on May 17, 2026 at 7:32 pm

    Few years ago, some DataSnap server I worked on had to pull data from a very-very slow SQL Server 7 server. I then worked out a server cache “toy” based on TClientDataSets where “cached providers” are connected to those “server ClientDataSets” which in turns reads data from file cache or from database.

    Cache was refreshed based on a set of specific hard-coded rules for each dataset. When the cache needs to be refreshed, server-ClientDataSet use a provider to pull data from database via ADOQuery and then the data is saved to the app-server disk using TClientDataSet’s binary format. (it enables cache sharing between server instances).

    To prevent different instances to pull information from database at the same time when it determines is time to update cache, very basic synchronization method was developed. A “control file” is created on disk during the data-retrieveral operation and deleted upon completion or failure. Before pull-data operation starts, the server instance checks for file existence. If it exists, enter a wait-loop until the file is not present and check for valid data in the .cds asociated file… and act according to that.
    If file don’t exists, tries to create it, covering the very same millisecond case.

    This was not a 24×7 application, just a kind of 12×6 :D. The method proved to be very good, I can’t remember a single failure for this rude synchronization during almost 3 years I was maintaining that code.. but you maybe want to create a more robust mechanism.

    When there’s no need to refresh the cache, data is just loaded from disk.

    All the cache work was done using the provider methods.

    So, the relation was something like this:

    //
    //     Client                    Server
    //---------------    -----------------------------------------------------------------
    //                                               Cache refresh?
    //
    //                                                   Yes
    //                                                  ----- Provider --- ADOQuery - DB
    // ClientDataSet ---- Provider --- ClientDataSet --|
    //                                                  ----- LoadFromFile
    //                                                   No
    //
    //
    

    Pseudo-code for need-to-update check and OpenDataSet was like this:

    function CacheRequiresRefresh: Boolean
    begin
      if not IsPresentLocalData then
        Result := True
      else if ControlRecordIsMoreRecent then
        Result := True
      else if SomeOtherCondition then
        Result := True
      else
        Result := False;
    end;
    
    function OpenDataSet;
    begin
      repeat
        if CacheRequiresRefresh then
        begin
          if not ControlFilePresent then
            if CreateControlFile then
            begin
              ConnectCDSToProvider;
              CDS.Open;
            end
          else
            if ControlFilePresent then
              WaitUntilControlFileIsNotPresent
        end
        else
          CDS.LoadFromFile('filename.cds');
      until CDS.Active;
    end;
    

    I don’t have access to the code anymore, sure I can’t remember every detail, happily current servers are very good and fast enough not to need to think on this now… hope explained mechanism the way it worked. If you need clarification or further help, please commment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im using a gridview to display data taken from a dataset which looks like
i have a dataset which im using to calculate some sales figures, this data
I currently have a dataset which has two columns that I'd like to compare.
I have a DataSet which I get a DataTable from that I am being
I'm trying to set up user-friendly captions in a DataSet which will be detected
I'm building a webservice which has a webmethod returning a Dataset object. I'm having
Does anyone know of examples which show how to encrypt a dataset at the
I have a web service which has a generic function that returns a dataset
I've got an in-memory dataset with several fields, one of which is a primary
Which of the dataset formats listed at this link is the easiest to load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.