[plt-scheme] Is there such a thing as "persistent memoization"?

From: Eric Hanchrow (offby1 at blarg.net)
Date: Mon Jul 9 21:12:30 EDT 2007

I have some code which does a lot of network operations, and for each,
retrieves a bit of data.  As it runs, it accumulates this data in
memory.  If a network operation fails, the program dies, and all the
data is lost because I haven't bothered writing it to disk.  (If all
the network operations succeed, the program computes a result from the
data, and no longer needs it.)  After a failure I naturally restart
the program, which painstakingly retrieves, a second time, all the
same data that it retrieved the first time.

Network operations fail distressingly often.  So I'd like to somehow
write each piece of data to persistent storage, as soon as I've gotten
it; and naturally I'd like the program to load up any such persistent
data when it starts.  What's more, I am inveterately lazy and don't
want to have to write much code for this; my fantasy would be that I
could find a form called, say, "define/memoized/peristent" that is
similar to the "define/memo*" in dherman's "memoize" package
... except of course the memoizations are persisted.  Does anything
like this exist?

Always code as if the guy who ends up maintaining your code will
be a violent psychopath who knows where you live.
        -- John F. Woods

Posted on the users mailing list.