Add ability to use Distributed Cache
I've implemented an ICachingProvider with an IDistributed cache implemented with Redis but I'm not able to succeffully serialize a TemplateCacheItem because is not serializable. I've tried Binary serializer, JSON, Protopuf and MessagePack but no one works. Only inMemory cache work.
I need a serializable object. :-D
Your template is built by Roslyn and put into in-memory assembly. Because of that, sharing between multiple instances is not possible at the moment. Possible solution is to add ability to compile templates into real DLLs
Can you describe your use-case? You have multiple application servers and you'd like to cache templates to Redis, so they can be shared between all of those instances?
It's exactly my case. I have many instance of my application in a docker stack and i would to cache template only one time in redis.
In general, having all your servers to compile and cache templates is not bad at all.
If you are storing your templates in files, when file with your template changes - all templates will be invalidated from cache from all your servers, so you don't have to bother about this aspect.
You can also warm-up your containers by compiling all the templates before start. Or use Precompiled templates, feature I haven't done yet :P
But having an ability to use Redis for templates cache sound very nice for me, and it would definitely be interesting to develop :)
In general, having all your servers to compile and cache templates is not bad at all.
If you are storing your templates in files, when file with your template changes - all templates will be invalidated from cache from all your servers, so you don't have to bother about this aspect.
You can also warm-up your containers by compiling all the templates before start. Or use Precompiled templates, feature I haven't done yet :P
But having an ability to use Redis for templates cache sound very nice for me, and it would definitely be interesting to develop :)
Probably forgotten but have this been picked up ?
Please see the comment
Your template is built by Roslyn and put into in-memory assembly. Because of that, sharing between multiple instances is not possible at the moment
Not possible to deliver "mobile code" via distributed cache. It's a fundamental limitation.
Cache the end results, not the templates.
Please see the comment
Your template is built by Roslyn and put into in-memory assembly. Because of that, sharing between multiple instances is not possible at the moment
Not possible to deliver "mobile code" via distributed cache. It's a fundamental limitation.
Cache the end results, not the templates.
I see the limitation But I do not believe in caching end results since that defeats the purpose of using templates. end results will change based on data you provide so it should not be cache unless I am missing something.