anchor.diff:          [] -> {noreply, State};
           Cs ->
               lager:debug("flushing metric cache of ~p (~w entries)",
  -                        [State#state.path, length(Cs)]),
  +                        [State#state.path, State#state.cache_size]),
   
               File = State#state.fspath,
               case statser_whisper:update_points(File, Cs) of
                   ok ->
  -                    statser_instrumentation:increment(<<"committed-points">>, length(Cs)),
  -                    {noreply, State#state{cache=[]}};
  +                    statser_instrumentation:increment(<<"committed-points">>, State#state.cache_size),
  +                    {noreply, State#state{cache=[], cache_size=0}};
                   _Error ->
                       % archive is not existing (yet)
                       % so dispatch a creation via rate-limiter
  
positive.code:     ].
  
  cache_sorted_test_() ->
      [?_assertEqual([{120, 10}, {110, 10}, {100, 10}],
                    cache_sorted(10, 120, [{110, 10}, {100, 10}])),
       ?_assertEqual([{120, 10}, {110, 10}, {100, 10}],
                    cache_sorted(10, 110, [{120, 10}, {100, 10}])),
       ?_assertEqual([{120, 10}, {110, 10}, {100, 10}],
                    cache_sorted(10, 100, [{120, 10}, {110, 10}])),
       ?_assertEqual([{120, 11}, {110, 10}],
                    cache_sorted(11, 120, [{120, 10}, {110, 10}])),
       ?_assertEqual([{120, 10}, {110, 11}],
                    cache_sorted(11, 110, [{120, 10}, {110, 10}]))
      ].
  
  
  merge_with_cache_test_() ->
      Cache = cache_sorted(16, 160, [{120, 12}, {110, 11}, {100, 10}]),
      Test = fun(Values) ->
                     Series = #series{values=Values},
                     merge_with_cache(Series, Cache)
  
negative.code:     case State#state.metadata of
          #whisper_metadata{archives=[A | _]} ->
              AlignedTS = TS - (TS rem A#whisper_archive.seconds),
              {Cache, Added} = cache_sorted(Value, AlignedTS, State#state.cache),
              CacheSize = State#state.cache_size + Added,
              State#state{cache=Cache, cache_size=CacheSize};
          _Otherwise ->
              State
      end.
  
  
  cache_sorted(Value, TS, []) ->
      {[{TS, Value}], 1};
  cache_sorted(Value, TS, Cache) ->
      cache_sorted(Value, TS, Cache, []).
  
  cache_sorted(Value, TS, [], Acc) ->
      {lists:reverse(Acc) ++ [{TS, Value}], 1};
  cache_sorted(Value, TS, [{TS1, _}=P | Ps]=Pss, Acc) ->
      if TS == TS1 ->
             {lists:reverse(Acc) ++ [{TS, Value} | Ps], 0};
         TS > TS1 ->
             {lists:reverse(Acc) ++ [{TS, Value} | Pss], 1};
         true ->
             cache_sorted(Value, TS, Ps, [P | Acc])
      end.
  