Memoize a value with a decorator