The cacheresults attribute controls whether the results of a function are cached.
You can control the value of the attribute with the Cache Results command on the Function menu of the XLL+ AppWizard. This item also appears on the drop-down menu of the Edit Function Attributes tool-button.
You can also edit the value for the current function in the Edit Function Attributes window. The window can also be used to set the default value of the attribute, which will then be applied to all new functions.
If the flag is set to true the function header will include lines like the following:
CXlCacheBinding<XLP_CACHE_CLASS> bind__(XllGetTypedApp()->m_cache, xloResult, "FunctionName", &FirstArg, true); if (bind__.Find()) return bind__.Ret();
The impact of this code is as follows:
You can add a cache to a new add-in project by selecting the "Results cache" option in the XLL+ AppWizard. See XLL+ AppWizard for Visual Studio 6 or XLL+ AppWizard for Visual Studio .NET & Visual Studio 2005 for more information.
If you have already created a project, and you wish to add a cache, follow these steps:
Include xlserialize.h in your project header file, after the line that includes xllplus.h.
#include <xlserialize.h>
Add a public variable m_cache of type CXlOperCache to your project class.
class CAvgOptApp : public CXllApp
{
public:
CAvgOptApp();
// Names
public:
static LPCSTR m_pszDefName;
// Data
CXlOperCache m_cache;
// Overrides
// ClassWizard generated virtual function overrides
...
};
If your header file does not contain a definition of XllGetTypedApp(), then add one, as in the following example.
CAvgOptApp* XllGetTypedApp() { return (CAvgOptApp*)::XllGetApp(); }
The function will be used by code generated by the XLL+ Function Wizard.
Function Wizard | Cache Results command | CXlOperCache class