Take context into account when memoising results.