Odpovědět Shared Cache with OutputCache

  • 16. července 2012 11:31
     
     

    Hi!

    I try to use Azure Shared Cache with MVC's Outputcache, however I run into several pitfalls.

    First of all, it does not work properly wih the Authorize attribute. On Stack Overflow I found several discussion about this question, but no proper answer.

    The real problem is invalidation: using the standard MVC cache, CacheDependency is used to create a second cache item, which has a known key so it can invalidated by me. This way when I invalidate my cache item from code, the origional MVC cached content is invalidated as well due to the dependency.

    Shared cache does not support cache dependency. So how can I invalidate an item? I can invalidate a page, but this way I cannot cache user dependent data.

    I have tryed to create the cache key (for invalidation) the same way as the OutputCache does, but it uses to many internal and private methods, thus I would need the whole source code of the DLL. (This way by implementing an own cache provider that internally uses the azure cache provider I could invalidate by myself.)

    Another solution is to create an own attribute implementing the ActionFilterAttribute, and do the same thing as the OutputCache attribute. But I run into the same problem as above. (that I need the whole DLL)

    So the real problem is that the OutputCache provider can be custom, but there is no way to override the Key Generation so I could use my own keys depending by the user's Id, and also which can be invalidated by myself from code.

    Has anybody run into this problem? What is the solution for this?

    Thanks,

    Laszlo

Všechny reakce