2

I have been evaluating NCache since the last few weeks. Mu question is specific to techniques for querying the cache data. I'm looking for something similar to the ADO.NET technique mentioned below. The requirement to to supply multiple queries at a go and iterate through the result set one by one.

The ADO.NET code for fetching in the above mentioned fashion from database looks like this.

connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password";
            sql = "Select top 2 * from product; select top 2 * from ordermaster; select top 2 * from orderdetails";

            sqlCnn = new SqlConnection(connetionString);
            try
            {
                sqlCnn.Open();
                sqlCmd = new SqlCommand(sql, sqlCnn);
                SqlDataReader sqlReader = sqlCmd.ExecuteReader();
                while (sqlReader.Read())
                {
                    MessageBox.Show ("From first SQL - " + sqlReader.GetValue(0) + " - " + sqlReader.GetValue(1));
                }

                sqlReader.NextResult();

                while (sqlReader.Read())
                {
                    MessageBox.Show("From second SQL - " + sqlReader.GetValue(0) + " - " + sqlReader.GetValue(1));
                }

                sqlReader.NextResult();

                while (sqlReader.Read())
                {
                    MessageBox.Show("From third SQL - " + sqlReader.GetValue(0) + " - " + sqlReader.GetValue(1));
                }

                sqlReader.Close();
                sqlCmd.Dispose();
                sqlCnn.Close();
            }

Can we do something similar in NCache for querying the cache data ?

The Mitra Boy
  • 764
  • 1
  • 6
  • 13
  • The available operators supported by NCache are listed here; http://www.alachisoft.com/resources/docs/ncache/help/oql-syntax.html . Is using the `TOP` keyword a necessary requirement ? – Basit Anwer Jun 14 '16 at 11:35
  • @BasitAnwer Thanks. TOP is not a necessary requirement. But the point is sending multiple queries at a go and retrieving the result sets one by one using something like NextResult() – The Mitra Boy Jun 17 '16 at 11:18
  • NCache doesn't support the `NextResult` command, but can you not achieve the same result by doing things asynchronous ? – Basit Anwer Jun 21 '16 at 04:29

1 Answers1

0

Supported queries in NCache are listed here;

http://www.alachisoft.com/resources/docs/ncache/help/oql-syntax.html

Above that, NCache doesn't support NextResult command but what you can have your own implementation to facilitate your application

//Psuedo Code

  1. Create a list of queries
  2. Create a wrapper wrapping NCache query Client API
  3. Execute those queries in an async manner
  4. Create a NextResult function in your Wrapper
  5. Perform synchronization on the async threads to block or run on NextResult method (Joins or Mutex.wait e.t.c) to wait for the async query operations methods to return back
  6. Do what you wanted to do :)

Its a custom implementation. You don't actually need to do it since NCache is completely In-Memory therefore SQL queries should be very fast already.

You could make a feature request though on Alachisoft Forums

Basit Anwer
  • 6,742
  • 7
  • 45
  • 88