[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apr-dev
Subject:    =?UTF-8?Q?apr=5Freslist=20TTL=20values=20are=20in=20usecs?=
From:       Michael Spiegle <mike () nauticaltech ! com>
Date:       2009-07-16 2:09:25
Message-ID: 961d47e3a9395a77ec7edf4ee3f3fc1e () localhost
[Download RAW message or body]


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic