Szerző: Avleen Vig Dátum: Címzett: exim-users Tárgy: Re: [Exim] Interesting tidbit on selecting domains from MySQL, + feature request
On Fri, Jul 04, 2003 at 09:59:44AM +0100, Philip Hazel wrote: > There are two different issues here:
>
> (1) Caching of lookups;
> (2) Caching of the results of matching against a named list.
>
> 1. Caching of lookups:
>
> For lookups, Exim caches only the result of the most recent query for a
> given file or database. This goes back to the very early days of Exim,
> when there were only lsearch and dbm-type lookups. A single-entry cache
> works well for simple cases (e.g. checking "domains" in several
> successive routers). I have not re-visited this code for a long time.
>
> I would expect the result of the db lookup to be cached in this sense.
> The debug output should show a message of the form "cached data used for
> lookup of...". However, if there were other mysql lookups in between,
> you won't see this (owing to the one-levelness of Exim's cache).
>
> Exim does cache the connection to the server. I suppose Exim could
> maintain a larger cache of queries, but how large should it be? I think
> I might argue that a better place for this caching is in the database
> server itself (compare DNS name servers).
The cache should be able to hold "several" lookups, for the period of
the connection, or until RSET is sent.
While the database should have its own cache, caching these results for
the length of a connection reduces network traffic, and can speed up
lookups (even if the database is running on localhost).
As load and volume increase, these saved lookups can be worthwhile I
think.
> 2. Caching of matches against a named list
>
> This is what you are seeing in the debug output you quoted. If, while
> routing an address, the domain is matched against a named list such as
> +local_domains, the result is cached, BUT only if the string that makes
> up the domain list contains no expansion items. It would be wrong to
> cache strings that can potentially be different every time. That is why
> this type of caching is not happening when you are using a lookup to
> generate the domainlist. At that level, all Exim sees is "match domain
> to this list; this list contains a $ so it might be different each
> time; therefore don't cache".