apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Spiegle <m...@nauticaltech.com>
Subject apr_reslist TTL values are in usecs
Date Thu, 16 Jul 2009 02:09:25 GMT

I was writing a module which takes advantage of apr_memcache to cache file
objects.  Apr_memcache uses apr_reslist (which I'd like to say is really
awesome), but the documentation/api is slightly flawed in my opinion:

The documentation for apr_memcache_server_create() states that the TTL is
specified in seconds
(http://apr.apache.org/docs/apr-util/1.3/group___a_p_r___util___m_c.html#g18ddd72bc1ab5edb0a08a8f26f193bd3).

The documentation for apr_reslist_create() doesn't make a distinction of
the time unit.  It just says "time"
(http://apr.apache.org/docs/apr-util/1.3/group___a_p_r___util___r_l.html#g608ebcddce542603a7f1d3cf51ae8d3c).

In reality, apr_reslist_acquire() uses apr_time_now() to compute TTL
values.  The issue here is that apr_time_now() reports microseconds since
epoch:
APR_DECLARE(apr_time_t) apr_time_now(void)
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec * APR_USEC_PER_SEC + tv.tv_usec;
}

I banged my head on the desk for a bit on that one.  IMO, the TTL value
should be in seconds which seems more natural to me, but accurate
documentation would have worked too.

In any case, thanks for all the hard work on the APR libs.  I'm new to
apache development, but am definitely enjoying the entire apache framework.


-- 
Michael Spiegle
mike@nauticaltech.com

Mime
View raw message