EFCaching Config
Note
This feature is only available in NCache Enterprise edition.
EFCaching configuration file contains information regarding Entity Framework
provider. It is installed with NCache and is located at
[InstallDir]/config
. efcaching.ncconf is used for enabling NCache
in Entity Framework applications. The configurations are stored in
an efcaching.ncconf file.
EFCaching configuration file is explained below:
- Provider Configuration contains cache and caching policy related information. Below are the changes required in efcaching.ncconf.
<configuration>
<app-config app-id = "PersonNameApp" mode = "analysis|caching">
app-id: Is an identifier for an application. The configuration can contain multiple configuration settings for different applications. App-id for efcaching.ncconf should be same as in application otherwise it will prompt an error.
Mode: Can either be "Analysis" or "Caching". (Hot Applicable). Default = 'Caching'
"Analysis" mode is used for monitoring the number of times each query executes and then it generates a report. Report contains the Query text and the call count for each query. This report can be used in Custom policy. No caching is done at this mode.
<analysis-policy log-path = "" analysis-time = "60" cache-enable-threshold = "5" default-expiration-type = "absolute|sliding" default-expiration-time = "180" dbsyncdependency = "true"/>
Log-path: Path at which analysis log files will be generated. Default =
<InstallDir>/log-files/efcaching-analysis-logs/
Analysis-time: Time for which the analysis will run. Default = 60 min
Cache-enable-threshold: Caching will automatically be enabled for queries whose call-count exceeds this threshold. Default = 5
Default-expiration-type: Default expiration type for analyzed queries. Default = absolute
Default-expiration-time: Default expiration time for analyzed queries. Default = 180 sec (3 min)
dbsyncdependency: Determine whether to enable database-dependency or not. Default = "true"
For "Caching" mode, wrapping provider will cache the results of all the specified queries. Caching mode works on either
cacheall
policy orcustom
policy. Both policies have their own specifications. Whenever update is detected (either UPDATE, INSERT or DELETE) in a respective database, the provider invalidates affected cache entries by evicting all cached queries which were dependent on any of the updated tables.
<cache-policy default-policy = "cacheall|custom" database = "none|oracle10i2|sqlserver" cache-id ="mycache" enabled = "true">
Default-policy: The default policy for caching. (Hot Applicable). Default =
'cacheall'
Database: Database information is collected to create database sync dependency. (Hot Applicable). Default =
'none'
Cache-id:: Name of the cache. Default =
'mycache'
Enabled: Determine whether the policy is in effect or not. (Hot Applicable). Default =
'true'
For
cacheall
policy, it caches all the queries and their results.
<cacheall-policy expiration-type = "absolute|sliding" expiration-time = "1800" dbsyncdependency ="true"/>
Expiration-type: Type of expiration, it can be 'sliding' or 'absolute'. Default =
'absolute'
.Expiration-time: Default = 180 sec (3 min)
dbsyncdependency: Determine whether to enable the database-dependency or not. Default =
'true'
For custom policy, it includes user-configurable list of queries that should be cached with their results. When custom policy is selected, only those queries results will be cached for which the caching is enabled. You can also specify custom caching policy for all queries.
<custom-policy>
<query query-text = "" ["SELECT FROM Products"] | stored-procedure-name = "" ] caching ="true" expiration-type = "absolute"| sliding = "" expiration-time = "180" dbsyncdependency ="true"/>
</custom-policy>
</cache-policy>
</app-config>
</configuration>
Query-text: Text of the query whose result is to be cached OR name of a stored procedure whose output is to be cached.
Caching: Determines whether caching is enabled for this query or not. Default =
'true'
Expiration-type: Type of expiration, it can be 'absolute' or 'sliding'. Default =
'absolute'
.Expiration-time: Default = 180 sec (3 min)
dbsyncdependency: Determine whether to enable database-dependency for analyzed queries. Default = "
true
"In case of stored procedures, query text will be the name of a stored procedure, and there will be no default policy or database sync dependency.
User can cache stored procedures result with expiration only, no database dependency is needed here.