[plt-scheme] Caching database rows

From: Henk Boom (lunarc.lists at gmail.com)
Date: Sat Mar 8 01:03:00 EST 2008

Hi,

I am mapping sqlite rows of a certain table onto my own "node" struct
type, by filling it's fields with information from the database.
Things get dicey when the records in the database are changed or
removed: I want to automatically update old node objects when a row in
the database is modified. To do this, I imagine caching all retrieved
nodes so that I have access to them when I need to either correct or
invalidate them. I can think only of the following way to implement
this:

A hash-table of integers (row ids) to weak-boxed node structures. I
would attach wills to the nodes to remove the key-value pair from the
hash-table when they are no longer referenced.

This sounds to me like a complicated solution to what should be a
simple problem. Is there a nicer way to accomplish this?

Please let me know if my explanation is incoherent, it seems I've been
mulling this over long enough that I've lost the ability to see what
parts are obvious or not.

    Henk


Posted on the users mailing list.