Function decorator for persistent memoization