Origin buffer memoization

This provides functions to memoize for functions which run over buffer contents, and the cache will last until the buffer contents change.