I'm looking for a real simple example of how to add an object to cache, get it back out again, and remove it.
The second answer here is the kind of example I'd love to see...
List<object> list = new List<Object>();
Cache["ObjectList"] = list; // add
list = ( List<object>) Cache["ObjectList"]; // retrieve
Cache.Remove("ObjectList"); // remove
But when I try this, on the first line I get:
'Cache' is a type, which is not valid in the given context.
And on the third line I get:
An object method is required for the non-static field blah blah blah
So, let's say I have a List<T>
...
var myList = GetListFromDB()
And now I just wanna add myList
to the cache, get it back out, and remove it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…