I currently have 2 static dictionaries in a wcf restful service. These both hold look up data that's not worth putting in a database. Will these stay in memory until the application restarts or should I put them in HttpContext.Current.Application?
Asked
Active
Viewed 493 times
0
-
WCF by default is **not** the same as an ASP.NET application - so by default, you **don't have** access to things like `HttpContext.Current` in a WCF service. I would put those dictionaries into a persistent store - a.k.a. database. That's the easiest and most efficient way to handle data shared amongst instances of a WCF service. – marc_s Jun 17 '13 at 20:35
1 Answers
0
The static data will remain until the process recycles or stops, the same as HttpContext.Current.Application.
If you are looking for a more sophisticated caching option, check out the System.Runtime.Caching namespace introduced in 4.0. It is easy to use, works in any .NET application, and offers features like setting expiration times and creating callback functions to execute on expire.

Jason
- 651
- 5
- 10