MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.35k stars 456 forks source link

Feature request: be able to configure output cache from c# along with web.config #169

Closed hermesramos closed 7 years ago

hermesramos commented 7 years ago

Please!

THanks

MichaCo commented 7 years ago

@hermesramos Is there any other way but web.config to define a custom OutputCacheProvider? If so, please let me know, couldn't find anything. If you cannot configure it by code, I can also not inject anything to it by code. Which means, sorry, this is not possible.

hermesramos commented 7 years ago

Do you know if it is possible to only set the outputcache in the web.config and set the remaining configuration in the c# (redis and stuff)?

As of know, because of the output cache, I am setting everying in the web.config.

Thanks in advance

MichaCo commented 7 years ago

Thats what I meant, there is no way to easily connect the two things, I have no control over when the outputcache thing gets initialized to inject a CacheManager instance which was created in your startup code. Would eventually be possible to do via static property or something, but that would be such a horrible design that I'm not willing to implement it ;)

hermesramos commented 7 years ago

Sorry for my poor english, I was not clear enough.

Can I combine configuration from C# , like bellow, with outputcache from web.config?

var cache = CacheFactory.Build<string>("myCacheName", settings =>
{
    settings
    .WithSystemRuntimeCacheHandle("handle1")
  .And
  .WithRedisCacheHandle("redis");
});

with

<system.web>        
  <caching>
    <outputCache defaultProvider="CacheManagerOutputCacheProvider">
      <providers>
        <add cacheName="myCacheName" name="CacheManagerOutputCacheProvider" type="CacheManager.Web.CacheManagerOutputCacheProvider, CacheManager.Web" />
      </providers>
    </outputCache>
  </caching>
</system.web>

will this work? I tried but could not make it work

MichaCo commented 7 years ago

np ;) As I said, nope, that's not going to work

hermesramos commented 7 years ago

Alright! Thank you very much for your time.