Simple Data Caching using Weak References in WCF

Posted by Tawani on Stack Overflow See other posts from Stack Overflow or by Tawani
Published on 2010-04-02T17:44:59Z Indexed on 2010/04/02 17:53 UTC
Read the original article Hit count: 631

Filed under:
|
|
|

Given that I have the following WCF service:

class LookUpService
{
   public List<County> GetCounties(string state)
   {
       var db = new LookUpRepository();
       return db.GetCounties(state);
   }
}

class County
{
    public string StateCode{get;set;}
    public string CountyName{get;set;}
    public int CountyCode{get;set;}
}

What will be the most efficient (or best) way to cache a state's counties using weak references (or any other approach) so that we don't hit the database every time we need to look up data.

Note that we will not have access to the HttpRuntime (and HttpContext).

© Stack Overflow or respective owner

Related posts about weak-references

Related posts about c#