next up previous contents
Next: Subscriptions Up: Item Caching and Subscriptions Previous: Item Caching and Subscriptions   Contents

Item Caching

OPC XML-DA servers normally retrieve data from underlying systems, such as fieldbuses. Different client will then access these items through the OPC server. There may be situations, where many clients access the same OPC item over and over. These client requests will therefore lead to a significant load on underlying systems and may even exceed their capabilities.

One solution to this problem is caching: when the OPC server retrieves an item from an underlying system, it stores it for a predefined amount of time. These cached items are then available for OPC clients, therefore client requests do not necessarily lead to data retrieval from underlying systems.

In the client request message, the option ``MaxAge'' may be specified, denoting how old the item may be. If MaxAge is greater than the time the item is cached, the server will build the response message upon the cached item, otherwise the server will retrieve new data.

The PyOPC framework does automatically implement OPC item caching, if the server attribute ``AutoItemCache'' is set to true (which it is by default). The developer can also specify the attribute ``DefaultMaxAge'', which defines the maximum age in milliseconds for requests that do not provide the MaxAge option.

The exact item caching mechanism is illustrated in figure 8:

Figure 8: Mechanism of PyOPC Item Caching
\begin{figure}\centering
\includegraphics[scale=0.7]{graphics/item_caching.eps}\end{figure}

If an OPC Read request message is received by the server and ``AutoItemCache'' is set to true, the XDAServer method ``CachedRead'' is called. This method decides whether to return cached data regarding the MaxAge parameter or whether it calls the server's read method, which retrieves the data from the underlying system.

This way, the developer does not need to regard item caching, he has to code only the data retrieval itself. His read method will be only called if the maximum allowed age is smaller than the time, the item is cached.

Write operations update data in underlying devices. Therefore by default the read cache of a written item is flushed. However, in certain situations it may be appropriate not to clear the cache. Therefore PyOPC provides the option ``WritePurgeCache'' which can be set to false to omit the automatic cache flushing.


next up previous contents
Next: Subscriptions Up: Item Caching and Subscriptions Previous: Item Caching and Subscriptions   Contents
Hermann Himmelbauer 2006-11-07