Class AddressCache.

Inherits Garbage

This class maintains a cache of the addresses in the database.

This class is responsible for finding the numeric id of an Address object. It may find the id in its in-memory cache, or by issuing a SELECT against the addresses table, or, failing that, by inserting a new row into the table and retrieving its id.

(...We want to describe the id-lookups here...)

Each entry in the addresses table must be unique. Instead of using an explicit lock to serialise insertions by multiple Injectors, we simply add a UNIQUE(name, address, localpart) clause to the table, and allow duplicate INSERTs to fail.

(...We need to talk about synchronisation through ocd here...)

This class is used only by the Injector at present.

static CacheLookup * AddressCache::lookup( Transaction * t, List< Address > * l, EventHandler * ev )

This function accepts the List l of Address objects, and notifies ev after it has called Address::setId() for each Address in l. Cached addresses will be resolved immediately. Uncached ones incur a database lookup, and possibly an insert followed by a select, before being added to the cache.

Any required queries will be run in the Transaction t.

(We assume, for the moment, that none of the queries will fail.)

static void AddressCache::setup()

This function initialises the cache of Address objects at startup. It expects to be called from ::main().

This web page based on source code belonging to Oryx Mail Systems GmbH. All rights reserved.