ADO.NET provider for Salesforce / Caching
In This Topic
    In This Topic

    Caching data provides various advantages like faster data access and minimizing the calls to API which improves the overall process. The DataConnector supports an easy-to-use caching procedure where several connections can also share the cache.

    User can set necessary connection properties to enable caching feature. For example, Cache Tolerance property that ensures data fetched from the database is the latest version and Cache Location property which is the location in physical drive.

    The default tolerance of the stale data in cache is 600 seconds and the default location is %AppData%/C1DataConnector.

    The below code example implements caching, by setting Use Cache to True which is False by default, in the file specified by the Cache Location property of the connection string.

    Copy Code
    //Set Use Cache to True, and Cache Location to a valid location to enable caching
    //Cache Tolerance is time in minutes, Cahe location is location in physical drive
    static String connectionString = $@"{GCSalesforceServerConnectionString}; Use Cache = true; Cache Tolerance = 500; Cache Location = 'C:\Windows\Temp\c1cache.db'";
    static void DataReaderSelect()
        Console.WriteLine("Start Time " + DateTime.Now);
        using (C1SalesforceConnection con = new C1SalesforceConnection(connectionString))
            var cmd = con.CreateCommand();
            cmd.CommandText = "SELECT AccountId,Status,BillingState from [Order] limit 10";
            DbDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
                Console.WriteLine(String.Format("\t{0} --> \t\t{1}-->\t\t\t{2}", rdr["AccountId"], rdr["Status"], rdr["BillingState"]));
            Console.WriteLine("End Time " + DateTime.Now);