I am looking for an c# object cache library that can implement the following patterns:
- the cache is used to cache objects of a certain type T that have a primary key. Example: a Person class (with first name, last name etc) and the key is PersonId
- the cache can store an unlimited # of keys. The keys are of type int or long.
- the cache, however, can store only a limited # of objects of type T. T objects take a lot of memory and I can't have lots of these objects in the cache at a time.
- on overflow the cache can serialize the objects to a database or file etc. (fast medium) but the cache would still keep around the keys.
I basically need to process more T objects than I can keep in the memory and I want to use the cache to retrieve them quickly before I save the results to the database.
So, I was thinking of using the Proxy pattern and have the cache store proxy objects that can get/serialize my real objects.
Do you know any caching c# library that can be used with these patterns? I haven't been able to find anything myself.