I am planning to create a Sharepoint Timer开发者_开发问答 Job and configure it to run on all of our farm web front end machines.
The timer job will read data from the SP SQL Server instance and hopefully update it into the HTTPRuntime cache object on the 2 Web FTEs that we have.
The question is this, will the Timer Job have access the ASP.net cache objects or will they not because they're running from owstimer.exe?
If not, what would be the best way of going about updating a cache item on the 2 web front ends? I should mention that we current DO NOT have the IIS sites configured to be acessed seperately. I.e. we have one URL to access the farm and our content switch does the deciding which machine gets it.
So is it even possible?
You cannot access the cache directly no. The time jobs are running in a different process than then the application pool your website is running on.
You could do it indirectly though. A way I can think of would be to create a simple web service on your website that listens for your timer job and updates the cache on the website.
Another option would be to look into memcached for .NET, a project that allows you to access the cache from other processes.
It doesn't have to be the HTTP runtime cache if you want to access it from the WFEs, right? You could store it in a list perhaps? If that's too heavyweight, inefficient or just sounds silly to you then you could signal the WFEs to pull (or invalidate) the cached item by having your timer job stuff a flag into the SPWebApplication's Properties hashtable. This hashtable couldn't be used to store the item itself as it's limited to primitives like DateTime, bool, string, int etc.
精彩评论