Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I got following scenario. A web part needs certain configuration parameters (primitive data types) like e.g. an URL (string) to retrieve and show data from an external system. As each instance of the web part within a web application should retrieve the data from the same system, the parameters are stored in the SPPropertyBag of the web application so the web part knows where to look for it. The parameters are put to the property bag via an application page in the CA.

At the moment the web part uses a configuration object which implements the singleton pattern to access the configuration parameters stored in the property bag. The disadvantage is that the web part won't recognize a change of the configuration parameters until the application pool is reseted and the singleton object is newly created with the updated parameters.

Now I'm looking for a way to optimize this mechanism in such a way that the singleton object is able to recognized configuration changes and reread the parameters without killing the application pool.

I thought about some kind of caching mechanism which somehow informs the singleton object that the parameters have changed. I've read some articles about cache dependencies which might be a way to go but I'm not sure how to use them with SPPropertyBag objects.

So I'm wondering how you would handle this?

share|improve this question

2 Answers 2

I don´t have an exact answer for you but I would "off the top of my head" implement a kind of service, SettingService.cs, that could give you the settings from the property bag. These are "cached" through a singleton pattern but when you add/update a setting through that application page you would (with thread safety) inform your service that a change has been made and therefore re-read the property bag. I have been thinking about a similar pattern myself but not yet implemented one.

share|improve this answer

SharePoint Guidance (Patterns and Practices) has some guidelines and framework for handling property Bags. You can use the guidance and framework directly or follow the best practices around it. More infromation below:

http://spg.codeplex.com/

share|improve this answer
    
Perhaps I'm blind but I cannot find any help for my caching problem in this document. It only provides information about how to store configuration parameters within SharePoint but not how to do this with a focus on caching. –  Flo Nov 10 '10 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.