I've implemented (well almost) PerlSetVar/PerlAddVar/dir_config but I'm
a little bit confused of the correct spec. So please confirm.
PerlSetVar sets the key => val
that's easy.
PerlAddVar key val
pushes the value to the list. Now if I implement the whole storage with
apr_table_t, it's easy to do the settings, but a hell on retrieval, not
talking about speed as I have to go through the whole list to make sure
that some key doesn't have more than one value.
If I implement the storage as an apr_hash_t, the look up is much faster
and simpler (that's what we want, since we mostly do lookups at the run
time). But how do I maintain a list? Luckily apr_hash_t want a void type
for the value so I can pass it a list.
So what's the correct way to do it if we do it with apr_hash?
PerlSetVar to set a normal (char *key, char *val)
PerlAddVar first to do a lookup and
if the key is there already
if the value is a list, push to the end of the list
else retrieve the string, create a list and put it as a value
Now the retrieve procedure is as follows:
get the void val, look at it,
if it's a string return it, casting it in the right way)
else must be a list, return the list (casting it)
Alternatively we could always use a hash of lists and always add values
to the lists. Less logic, more space, slower on average (assuming that
it's rare that we have a more than one value for one key).
Which way should we take?
It'll be very nice if APR::Table could handle this automagically. Or
should we have a new apr class to handle hashes of lists?
---------
now the second part: dir_config
is that correct?
@values = $r->dir_config('key');
@values = $r->dir_config->{key};
%hash = $r->dir_config; # Hash of lists!
Thanks!
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]