anchor.diff:  match_rr({_, _, _} = Key) ->
       Time = times(),
       case ets:lookup(inet_cache, Key) of
  -	[{_,RR}] when RR#dns_rr.ttl =:= 0 -> %% at least once
  +	[{_,RR,_}] when RR#dns_rr.ttl =:= 0 ->
  +	    %% ttl=0 is served once (by the current process) as we request
  +	    %% a deletion immediately. It is served at least once concurrently.
  +	    %% Deletions are safe thanks to the use of safe_fixtable.
   	    ets:delete(inet_cache, Key),
   	    [RR];
  -	[{_,RR}] when RR#dns_rr.tm + RR#dns_rr.ttl < Time ->
  +	[{_,RR,_}] when RR#dns_rr.tm + RR#dns_rr.ttl < Time ->
   	    ets:delete(inet_cache, Key),
   	    [];
  -	[{_,RR}] ->
  -        %% This may fail if cache pruning removes this entry
  -        %% at the same time we are updating it, so ignore the result.
  -	    _ = ets:update_element(inet_cache, Key, {2, RR#dns_rr{cnt = Time}}),
  +	[{_,RR,_}] ->
  +	    %% Update the entry concurrently. If the server deletes it, we ignore
  +	    %% the result. If the server updates it, we will race on the time part
  +	    %% which should be close enough to each other (as we are racing).
  +	    _ = ets:update_element(inet_cache, Key, {3, Time}),
   	    [RR];
   	[] ->
   	    []
  
positive.code:     Next = ets:next(CacheDb, Key),
      OldT =
          case ets:lookup(CacheDb, Key) of
  	    [{_,RR}] when RR#dns_rr.tm + RR#dns_rr.ttl < Now ->
  		ets:delete(CacheDb, Key),
  		OldestT;
  	     [{_,#dns_rr{cnt = C}}] when C < OldestT ->
  		C;
  	     _ ->
  		OldestT
  
negative.code:     call({add_rr, #dns_rr { domain = Domain, class = Class,
  		       type = Type, ttl = TTL, data = Data}}).
  
  del_rr(Domain, Class, Type, _Data) ->
      call({del_rr, {Domain, Class, Type}}).
  
  res_cache_answer(Rec) ->
      lists:foreach( fun(RR) -> add_rr(RR) end, Rec#dns_rec.anlist).
  