On 17.12.2009 16:02, "Plüm, Rüdiger, VF-Group" wrote:
-----Original Message-----
From: Rainer Jung
Sent: Donnerstag, 17. Dezember 2009 15:56
To: [email protected]
Subject: Re: [Proposal for trunk] Extending RewriteMap,
Reusing ip network matches
On 17.12.2009 14:32, "Plüm, Rüdiger, VF-Group" wrote:
-----Original Message-----
From: Rainer Jung
Sent: Donnerstag, 17. Dezember 2009 13:38
To: [email protected]
Subject: [Proposal for trunk] Extending RewriteMap, Reusing
ip network matches
1) Extending RewriteMap
=======================
I plan to extend key file handling in text file RewriteMap. At the
moment keys are always matched as exact strings against the
map. I want
to add the ability to alternatively
a) match via regexp (and replace backreferences in the
found values)
Can you give an example for this?
Where are these regexps? In the map file or in the
expression of the Map in the RewriteRule?
The regular expressions are the first columns in the map file. The
actual keys searched for will be normal strings matched against those
regexps. The result returned is the second column with backreferences
resolved against the match from the first column and the key.
I see some performance issue with this approach since each time one thing
in the file changes *all* regexps need to be recompiled. If it is a large
file that changes frequently this can eat up a considerable amount of cycles.
Right, I noticed that to, when I just now started to implement to learn
more about possible problems. OTOH having the rules in one externally
managed file can still be nice even without using the reloading ability.
And if you do reload it, recompiling the regexps will likely be cheaper
than a full server restart because of changed RewriteRules.
At the moment as long as a key hasn't been looked up before (i.e. is not
cached), the file is opened for each lookup and read line by line. When
using regexps it would be necessary to keep the compiled regexps in
memory after the first file read (to avoid continuous recompilation).
So the first access to the file is expensive and we would also need some
more memory. The impl wouldn't change the behaviour of the existing
exact match case though.
Regards,
Rainer