Hello,
we are using OpenAccess ORM 2010.2.714.1
In our solution we have a Web Application and a Class Library (DAL) that we use to read the data stored in a SQL Server 2005 DB installed in another server. The OpenAccess features are enabled only for the DAL Class Library.
Everything works, but we have a “lookup” procedure that is very slow because there are many “select” on the same tables in the SQL DB to load the required objects.
So we have activated the L2 cache to load the entire table (objects) data in the cache and avoid the execution of many select in the DB.
But after we have activated the L2 cache, the select statements are continuing to be executed in the DB and the data are not read from the L2 cache.
We have added the L2 cache enablement in the App.config file (using the Telerik OpenAccess BackEnd Configuration settings menu) :
<backendconfigurations> <backendconfiguration id="mssqlConfiguration" backend="mssql"> <mappingname>mssqlMapping</mappingname> <l2CacheEnabled>True</l2CacheEnabled> <l2QueryCacheEnabled>True</l2QueryCacheEnabled> <l2QueryCacheMaxQueries>10000</l2QueryCacheMaxQueries> <l2CacheMaxObjects>1000000</l2CacheMaxObjects> <pmCacheRefType>STRONG</pmCacheRefType> </backendconfiguration> </backendconfigurations> We load the connection data dynamically, so also we have added in the sub AdjustForDynamicLoad the following parameters:
Dim assumedInitialConfiguration As String = "<openaccess>" _ & "<references>" _ & "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" _ & "</references>" _ & "<connections>" _ & "<connection id=""DatabaseConnection1"">" _ & "<databasename>" + lstrDatabaseName + "</databasename>" _ & "<servername>" + lstrServerName + "</servername>" _ & "<user>" + lstrUsername + "</user>" _ & "<password>" + lstrPassword + "</password>" _ & "<integratedSecurity>False</integratedSecurity>" _ & "<backendconfigurationname>mssqlConfiguration</backendconfigurationname>" _ & "</connection>" _ & "</connections>" _ & "<backendconfigurations>" _ & "<backendconfiguration id=""mssqlConfiguration"" backend=""mssql"">" _ & "<mappingname>mssqlMapping</mappingname>" _ & "<l2CacheEnabled>True</l2CacheEnabled>" _ & "<l2QueryCacheEnabled>True</l2QueryCacheEnabled>" _ & "<l2QueryCacheMaxQueries>10000</l2QueryCacheMaxQueries>" _ & "<l2CacheMaxObjects>1000000</l2CacheMaxObjects>" _ & "<pmCacheRefType>STRONG</pmCacheRefType>" _ & "</backendconfiguration>" _ & "</backendconfigurations>" _ & "</openaccess>" Dim dll As System.Reflection.Assembly = theObjectScopeProvider1.GetType().Assembly assumedInitialConfiguration = assumedInitialConfiguration.Replace("PLACEHOLDER", dll.GetName().Name) Dim xmlDoc As New System.Xml.XmlDocument() xmlDoc.LoadXml(assumedInitialConfiguration) Dim db As Database = Telerik.OpenAccess.Database.Get("DatabaseConnection1", xmlDoc.DocumentElement, New System.Reflection.Assembly() {dll}) theObjectScopeProvider1._myDatabase = db We have tried with “pmCacheRefType” = AUTO and =STRONG, but the result is the same.
For every class that we need to store in the L2 cache we have added the cache strategy parameter in the App.config file:
<extension key="cache-strategy" value="all" /> But every time in the same thread (web request) we read these objects the data are retrieved from the DB instead from the L2 cache.
This is the code used to read the objects:
Protected Function GetObjectList(Of T)(ByVal pstrQuery As String, _ Optional ByVal pblnForwardsOnly As Boolean = True, _ Optional ByVal parrParams As Object() = Nothing) As IList(Of T) Dim llist As List(Of T) = Nothing Dim lobjQuery As Telerik.OpenAccess.IQuery = mobjObjectScope.GetOqlQuery(pstrQuery) lobjQuery.ForwardsOnly = pblnForwardsOnly Dim lobjQueryResult As Telerik.OpenAccess.IQueryResult = lobjQuery.Execute(parrParams) If ((lobjQueryResult IsNot Nothing) AndAlso (lobjQueryResult.Count > 0)) Then llist = New List(Of T) For Each p As T In lobjQueryResult llist.Add(p) Next End If Return llist End FunctionThis is an example of pstrQuery:
SELECT office FROM clsDmlOfficeVOExtent AS office WHERE office.OfficeCode = $1In the “for each” loop if we test if the “p” object is cached we get:
mobjObjectScope.Database.Cache.IsCached(mobjObjectScope.GetObjectId(p)) = TRUE
The queries are executed in the same loop calling the GetObjectList function, so we have:
1) "SELECT office FROM clsDmlOfficeVOExtent AS office WHERE office.OfficeCode = ‘XX’"
2) "SELECT office FROM clsDmlOfficeVOExtent AS office WHERE office.OfficeCode = ‘YY’"
…
N) "SELECT office FROM clsDmlOfficeVOExtent AS office WHERE office.OfficeCode = ‘NN’"
We have enabled the log and every time we execute the same query with different parameter, the select is executed in the DB and the data are not retrieved from the L2 cache, so the operations are very slow.
Please can you help us?
Best Regards.
Joseph