Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

Object cache keys and equality

Posted on May 22, 2007

For some bizarre reason (meaning I really don’t know why), I have always built cache key values as strings when the key being represented is a set of values. On Friday, my eyes were opened to the fact that it is much better to create a rich object that represents the key values. The question then come down to equality testing of the reference type to make sure that the cache keys are correctly identified. Understanding Equality in C# on CodeProject is a concise article that was helpful for getting this right.