Cache an object in my Class Library

Cache an object in my Class Library

Old forum URL:

omarcusido posted on Tuesday, July 12, 2011

Hello everyone!!!

I have a Class Library project (Business Layer using CSLA) and I need to cache one object with some configuration values, these values are used at application level and I don't want to couple my Library with the UI so I can't use session. In the other hand I need that this object be accessible before the user login. Another issue is that the object cached must be secure (only must be accessible from my Application). I was reading about MemoryCache class in System.Runtime.Caching namespace but I don't know if exist a better way to do this.

Please help.

Best Regards.


JonnyBee replied on Wednesday, July 13, 2011

Which type of UI is your app using?

For a rich client use one of the Context objects in ApplicationContext.

LocalContext is only on the machine the process is running on.
ClientContext is transferred one way to server (when using remote dataportal)
GlobalContext is transferred both ways to and from server (when using remot dataportal).

Or you could create your own static or singelton context object to hold the configuration object.  

omarcusido replied on Wednesday, July 13, 2011

Hello JonnyBee...

Thank you very much for your answer, I'm using 2 types of UI (WEB and Windows), the context objects work with the Win UI but in the WEB only stay alive the time that takes the call to the server, Unfortunately I need this object cached for every calls made to the server.

I really appreciate your help.



omarcusido replied on Thursday, July 14, 2011

Hello Everybody...

I was testing a few solutions using the new MemoryCache class and works fine but I'm not sure about the security of the cached data (Maybe this data could be accessible from another location and this is one of my bigest concerns).

If somebody have a better idea please help me.


Best Regards.


Copyright (c) Marimer LLC