I dont know if is possible.
I want a class to encapsulate all Cache of my site. I thinking about the best way to do this to avoid conflict with keys.
My first idea is something like this:
public static TResult Cachear<TResult>(this Cache cache, Expression<Func<TResult>> funcao)
{
string chave = funcao.ToString();
if (!(cache[chave] is TResult))
{
cache[chave] = funcao.Compile()();
}
return (TResult)cache[chave];
}
Is the best way? Ty