The CachedAttribute is documented as:
/// A PostSharp aspect that will cache the return value of a method or property. The aspect can
/// be applied with no paraemters, in which case a single return value is cached for the method, or
/// with a varyByParameter method, which will result in a separate cached value for each input value of
/// the named parameter.
My question is, what's the deal with this "varyByParameter"?
As far as I can tell, there is only one constructor method on this attribute:
/// Initializes a new instance of the CachedAttribute class.
/// <param name="cache">
/// The name of the cache to store the data
public CachedAttribute(CacheName cache)
this.cache = cache;
and the OnInvocation method always calls the GetCacheKey method with the MethodInvocationEventArgs:
public override void OnInvocation(MethodInvocationEventArgs eventArgs)
// Get the full cache key
CacheKey fullCacheKey = this.GetCacheKey(eventArgs);
and the GetCacheKey method itself seems to always construct the fullCacheKey using the eventArgs params:
private CacheKey GetCacheKey(MethodInvocationEventArgs eventArgs)
var fullCacheKey = new StringBuilder(this.cacheKey);
object arguments = eventArgs.GetArgumentArray();
Am I missing something?
How can we config the attribute insAtance to specify which parameters should be used to determine whether a method invocation needs caching?
I'm not very familiar with PostSharp, so I apologize if I've pulled a n00b.
Thank you in advance for your help, and the great community contribution!