Memorizing and Caching in ReactiveUI

One thing that is useful in any kind of programming is having a look-up table so that you don't have to spend expensive calls to fetch the same data that you just had recently, since fetching the data and passing it around via parameters often gets ugly.

A better way is to use a cache; that is, to store values we've fetched recently and reuse them. A naive approach would be to store the data off in a simple Dictionary. This might work for a while, but you soon realize, as Raymond Chen, Microsoft's principal software design engineer, says, “Every cache has a cache policy, whether you know it or not.”

In the case of a Dictionary, the policy is unbounded—an unbounded cache is a synonym for “memory leak,” since ...

Get Programming Reactive Extensions and LINQ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.