memcached と eviction と expire

メモリが足りなくなった場合、memcached は LRU(?) に基づいてキャッシュの eviction を行うけど、expire が設定されているエントリは evict されないっぽい。... なんてことはありませんでしたorz

item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_time_t exptime, const int nbytes) {
...
        for (search = tails[id]; tries > 0 && search != NULL; tries--, search=search->prev) {
            if (search->refcount == 0) {
               if (search->exptime == 0 || search->exptime > current_time) {
                       STATS_LOCK();
                       stats.evictions++;
                       STATS_UNLOCK();
                }
                do_item_unlink(search);
                break;
            }
        }

http://code.sixapart.com/svn/memcached/trunk/server/items.c

実際に動かして確認したわけではないですが。