Progress® Telerik® Reporting R2 2017

Configuring Custom Cache Provider

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