I am trying to implement caching in my program. I have a web application that provides user access to some learning courses.When the user logs on I authenticate him from our database. Now, if access a different course from the list I don't want to go back to the database. Instead I want to store the value in cache for lets say 20 mins. The program should 1) Authenticate the user, and let him access the course. If he changes the course the program should look in cache. if the user id exists let him access the course without going back to server. 2) Provide a mechanism, that if after 20 minutes the user is still on the system, automatically update the time.so, that the user is not logged off. I tried something like this
Cache ch = new Cache();
ch.Add("key","value);
but I get null refernece exception in 2nd statement. I have never worked with caching before so will appreciate any pointers.