Progress® Telerik® Reporting R3 2017

Configuring Custom Cache Provider

Important note Important

The cache settings mentioned in this article are not obligatory, and they do not apply to the HTML5 Viewer or its Angular, WebForms and MVC wrappers. Details about the Cache Storage of the Reporting REST Service that works with the HTML5 Viewer are available in Cache Management: HTML5 Report Viewer and Reporting REST services and REST Service Storage Settings.

Except the preconfigured cache providers, additional providers can be used. To do that create a MyCache class that implements the Telerik.Reporting.Cache.Interfaces.ICache interface. Then implement the Telerik.Reporting.Cache.Interfaces.ICacheProvider interface and its only method should return a new instance of the MyCache class.

Example

public class MyCacheProvider : Telerik.Reporting.Cache.Interfaces.ICacheProvider
{
    public Cache.Interfaces.ICache CreateCache(System.Collections.IDictionary parameters)
    {
        return new MyCache(parameters);
    }
}
public class MyCache : Telerik.Reporting.Cache.Interfaces.ICache
{
    readonly System.Collections.Generic.IDictionary<string, byte[]> cache;

    public MyCache(System.Collections.IDictionary parameters)
    {
        // The 'parameters' dictionary is initialized from the Telerik.Reporting/Cache configuration section.

        this.cache = new System.Collections.Generic.Dictionary<string, byte[]>();
    }

    public bool HasValue(string key)
    {
        return this.cache.ContainsKey(key);
    }

    public byte[] GetValue(string key)
    {
        return this.cache[key];
    }

    public void SetValue(string key, byte[] value)
    {
        this.cache[key] = value;
    }

    public void Clear()
    {
        this.cache.Clear();
    }

    public void Dispose()
    {
        this.Clear();
    }
}

To register this new provider set the provider attribute of the "Cache" element to the class name which implements ICacheProvider. Under "Providers" child element of the "Cache" element, create a "Provider" element with the same name attribute as the provider attribute of the "Cache" element. The type attribute should be the assembly qualified name of MyCacheProvider type. The following code snippet demonstrates how to configure such custom provider:

<Telerik.Reporting>
  <Cache provider="MyCacheProvider">
    <Providers>
      <Provider name="MyCacheProvider" type="MyNameSpace.MyCacheProvider, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
        <Parameters>
          <Parameter />
        </Parameters>
      </Provider>
    </Providers>
  </Cache>
</Telerik.Reporting>

See Also