Hi Michal,
I don't think that works either. The limitation is the SendCacheOutput
: "Occurs only if the cached output is found...". Because the system checks only the default cache keys nothing is found for the manipulated key.
I found a solution which works for me by implementing custom CacheHelper
and overriding GetInternal
and InsertInternal
Methods:
[assembly: RegisterCustomHelper(typeof(CustomCacheHelper))]
public class CustomCacheHelper : CacheHelper
{
protected override object GetInternal(string key, bool useFullKey)
{
if(key.StartsWith("outputdata"))
{
string cookieValue = this.GetCustomCookieValue();
if(!String.IsNullOrEmpty(cookieValue))
{
key += "|myKey=" + cookieValue;
}
}
return base.GetInternal(key, useFullKey);
}
protected override void InsertInternal(string key, object value, CMSCacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, bool useFullKey)
{
if (key.StartsWith("outputdata"))
{
string cookieValue = this.GetCustomCookieValue();
if (!String.IsNullOrEmpty(cookieValue))
{
key += "|myKey=" + cookieValue;
}
}
base.InsertInternal(key, value, dependencies, absoluteExpiration, slidingExpiration, priority, onRemoveCallback, useFullKey);
}
}
I am not fully satisfied with the solution because of the direct key string manipulation, but nothing else seems to be working.
Still thank you Michal, your ideas put me on the right track.