Integration Your Way - (800) 235-7250
RSSBus ADO.NET Provider for Facebook
Questions / Feedback? Caching Automatically

Caching Automatically

With Auto Cache the RSSBus ADO.NET Provider for Facebook will automatically load data into the cache database each time you execute a SELECT statement. Each row returned by the query will be inserted or updated into the corresponding table in the cache database.

This is handled in a streaming fashion: each row is processed into the cache database from the original result set as you read the row from the returned FacebookDataReader object, so the data is not loaded twice. Any rows you do not read from the returned FacebookDataReader will not be updated in the cache.

Tip: When using Auto Cache, ensure you always read all rows from the returned FacebookDataReader.

When using Auto Cache, statements other than SELECT will be executed against the real data table, and not against the cache. This can cause the data in the cache to become out of date.

To access data in the cache with Auto Cache enabled, you need to use the pseudo-table name <table>#Cache. For example, to query the Statuses table in the cache, execute a "SELECT * FROM [Statuses#Cache]" statement.

Note: If you run non-SELECT statements on a table_name#Cache table, the changes will not be replicated on the real data source. You will need to keep track of any changes that you make to the cache if you want to keep them in sync with the real data source.

Cache the Statuses Table

The following example caches data in the .db file specified by the "Cache Location" property of the connection string. The database contains the Accounts table which is populated with the data from the Facebook data source.

C#

String connectionString = "Cache Location=C:\\cache.db;Auto Cache=true;Offline=false;Access Token=AZ153165481Z351381AAZZ;";
using (FacebookConnection connection = new FacebookConnection(connectionString)) {
  FacebookCommand cmd = new FacebookCommand("SELECT * FROM Statuses", connection);
  FacebookDataReader rdr = cmd.ExecuteReader();
  while (rdr.Read()) {
    Console.WriteLine("Read and cached the row with ID " + rdr["Id"]);
  }
}

VB.NET

Dim connectionString As [String] = "Cache Location=C:\\cache.db;Auto Cache=true;Offline=false;Access Token=AZ153165481Z351381AAZZ;"
Using connection As New FacebookConnection(connectionString)
  Dim cmd As New FacebookCommand("SELECT * FROM Statuses", connection)
  Dim rdr As FacebookDataReader = cmd.ExecuteReader()
  While rdr.Read()
	  Console.WriteLine("Read and cached the row with ID " + rdr("Id"))
  End While
End Using


 
Copyright © 2013 RSSBus Inc.
[x] close

Questions / Feedback?


Name:
Email:
Feedback:
Send Feedback