Code to Implement Custom Cache Components
Loader and Writer components are used within the Content Selection Framework (CSF) to load caches and write out campaign results.
Loader and Writer components can be apartment-threaded, because they are created, used once, and then destroyed by the same thread. This means that they can be written in Microsoft Visual Basic.
Loader and Writer components are implemented as pipeline components, although they are not intended to be executed in the context of a pipeline. They must implement the Execute method of the IPipelineComponent interface for the CacheManager object to be able to execute them. Further, if they require configuration, they must implement the SetConfigData method of the IPipelineComponentAdmin interface. The following tables provide details regarding this requirement.
Loader Component
Method to Implement | Details |
---|---|
IPipelineComponent::
Execute |
Required for the Loader component to execute.
The pDispContext parameter is set to the existing cache instance, if it exists, otherwise it is set to a new, empty cache object. If the cache object (specified by the LoaderProgId setting for the cache) is a Dictionary object, then the following additional entries are set:
The pDispOrder parameter is set to a new cache object based on the setting of the LoaderProgId property, normally a Dictionary object or an LRUCache object, which will become the new cache. The lFlags parameter is set to zero (0). The plErrorLevel parameter is ignored on return. |
IPipelineComponentAdmin::
SetConfigInfo |
Optional. Required only if the Loader component requires configuration. Will be called if LoaderConfig property has been set.
The pDict parameter is set to point at the Dictionary object specified by the LoaderConfig property. |
Writer Component
Method to Implement | Details |
---|---|
IPipelineComponent::
Execute |
Required for the Writer component to execute.
The pDispOrder parameter is set to the existing cache instance. Normally a Writer component will retrieve data from the cache to be written to disk. The pDispContext parameter is set to NULL. The lFlags parameter is set to zero (0). The plErrorLevel parameter is ignored on return. |
IPipelineComponentAdmin::
SetConfigInfo |
Optional. Required only if the Writer component requires configuration. Will be called if WriterConfig property has been set.
The pDict parameter is set to point at the Dictionary object specified by the WriterConfig property. |
' Create a Cache manager component and configure it
Set dictConfig = CreateObject("Commerce.Dictionary")
dictConfig("ConnectionString") = "Provider=SQLOLEDB;Integrated Security='SSPI';DataSource=local"
Set CacheManager = Server.CreateObject("Commerce.CacheManager")
CacheManager.LoaderProgId("advertising") = "Commerce.LoadAdvertisements"
Set CacheManager.LoaderConfig("advertising") = dictConfig
CacheManager.WriterProgId("advertising") = "Commerce.WriteEvents"
Set CacheManager.WriterConfig("advertising") = dictConfig
CacheManager.RefreshInterval("advertising") = 10 * 60
CacheManager.RetryInterval("advertising") = 60
Set application("CacheManager") = CacheManager
Now any web page in the application can quickly access the named schedule:
Set CacheManager = application("CacheManager")
Set dictSchedule = CacheManager.GetCache("advertising")
Copyright © 2005 Microsoft Corporation.
All rights reserved.