The ConfigurationCacheHelper object enables a pipeline configuration to be cached in memory for any subsequent load operation, helping to reduce the performance penalty associated with accessing a pipeline configuration (.pcf ) on disk.
Note The actual performance benefits obtained by using the configuration cache helper depend on your specific configuration. To properly assess this benefit, measure the results in your production environment.
A pipeline configuration can be saved in cache from a loaded pipeline by using the SaveToCache method, and later retrieved into a new instance of a pipeline by using the LoadFromCache method.
The following example shows an ASP file creating, loading, and executing a pipeline, using the configuration cache helper. The script attempts to retrieve a cached configuration. If the requested configuration has not yet been cached, the script loads the configuration from the Plan.pcf configuration file, and then saves the configuration in the cache for future use.
REM Create the pipeline
Set pipeline = Server.CreateObject("Commerce.MtsPipeline")
if VarType(pipeline) <> vbObject then
Response.Write "Failed to create the pipeline<P>"
end if
REM Response.Write "Created the pipeline<BR>"
set cacheHelper = Server.CreateObject("Commerce.ConfigurationCacheHelper")
if VarType(cacheHelper) <> vbObject then
Response.Write "Failed to create the ConfigurationCacheHelper<P>"
end if
on error resume next
cacheHelper.LoadFromCache pipeline, Application("PlanCache")
if Err.Number <> 0 then
REM likely that cache has not been initialized
REM so load the configuration from file
pipeline.LoadPipe "c:\Inetpub\wwwroot\mysite\config\Plan.pcf"
REM Save the pipeline configuration into the cache for next time
Application("PlanCache") = cacheHelper.SaveToCache(pipeline)
end if
REM Execute the pipeline
pipeline.Execute 1, orderform, ordercontext, 1
if Err.Number <> 0 then
errnum = Err.Number
errdesc = Err.description
Response.Write "Error " & errnum & " (" & errdesc & ") executing the pipeline<P>"
end if
pipeline = None
Alternatively, the configuration cache could be created in the Global.asa, so that each page could assume that the configuration is already present in the cache and would not need to have any code to load from the .pcf file.
If the configuration cache helper is used, the following script should be added to the site's Global.asa to delete the configuration cache entry and reclaim the memory when the application ends:
Sub Application_OnEnd
REM ... other code
Set pipeline = Server.CreateObject("Commerce.MtsPipeline")
if VarType(pipeline) <> vbObject then
goto ErrorRet
end if
set cacheHelper = Server.CreateObject("Commerce.ConfigurationCacheHelper")
if VarType(cacheHelper) <> vbObject then
goto ErrorRet
end if
on error resume next
cacheHelper.DeleteCacheEntry pipeline, Application("PlanCache")
pipeline = None
End Sub