anchor.diff:  %% Add a resource record to the cache if there are space left.
   %% If the cache is full this function first deletes old entries,
   %% i.e. entries with oldest latest access time.
  -%% #dns_rr.cnt is used to store the access time instead of number of
  -%% accesses.
   do_add_rr(RR, Db, State) ->
       CacheDb = State#state.cache,
       TM = times(),
       case alloc_entry(Db, CacheDb, TM) of
   	true ->
  -	    cache_rr(CacheDb, RR#dns_rr{tm = TM, cnt = TM});
  +	    cache_rr(CacheDb, RR#dns_rr{tm = TM, cnt = TM}, TM);
   	_ ->
   	    false
       end.
   
  -cache_rr(Cache, RR) ->
  -    ets:insert(Cache, {cache_key(RR), RR}).
  +cache_rr(Cache, RR, Count) ->
  +    ets:insert(Cache, {cache_key(RR), RR, Count}).
   
   times() ->
       erlang:monotonic_time(second).
  
positive.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, #dns_rr { domain = Domain, class = Class,
  		       type = Type, cnt = '_', tm = '_', ttl = '_',
  		       bm = '_', func = '_', data = Data}}).
  
  res_cache_answer(Rec) ->
      lists:foreach( fun(RR) -> add_rr(RR) end, Rec#dns_rec.anlist).
  
negative.code: %% Delete max N number of entries.
  %% Returns the number of deleted entries.
  delete_older(CacheDb, TM, N) ->
      true = ets:safe_fixtable(CacheDb, true),
      Res = delete_older(ets:first(CacheDb), CacheDb, TM, N, 0),
      true = ets:safe_fixtable(CacheDb, false),
      Res.
  
  delete_older('$end_of_table', _, _, _, M) ->
      M;
  