Microsoft’s Patterns and Practices team has always had a less than stellar reputation. Seen as something ‘other’, they rarely get the attention and respect that the rest of Microsoft’s .NET development teams. Their Enterprise Library consists of customizable components, all open source, that cover the scenarios that most development shops traditionally build on their own or find amongst open source projects ported from Java.
One such component has been promoted into full .NET Framework. Now known as System.Runtime.Caching, this is not only a caching library but also a framework for developing your own libraries. The ObjectCache defines the common operations that all caches should implement. It is paired with an in-memory implementation called MemoryCache. In theory wrappers for other caching products can be created, allowing developers to easily swap out for other implementations.
Cache invalidation can be triggered by events, which are represented by ChangeMonitor objects. Out of the box you only file-based and a SQL Server-based monitors, but others can be easily built. Quite unusual for API documentation in any langauge, the ChangeMonitor contains detailed information on how to correctly implement subclasses.