anchor.diff:  -export([init/1, handle_call/3, handle_cast/2,
            handle_info/2, terminate/2, code_change/3]).
   
  +-define(SYNC_INTERVAL, 5000).
  +
   %% API
   -export([start_link/1]).
   
  
positive.code:     {noreply, State}.
  
  handle_info({buckets, Buckets},
              #state{bucket=Bucket, map=Map,
                     vbucket_states=VBucketStates} = State) ->
      ?log_debug("Got `buckets` event"),
  
      BucketConfigs = proplists:get_value(configs, Buckets),
      BucketConfig = proplists:get_value(Bucket, BucketConfigs),
  
      NewMap = build_map(BucketConfig, VBucketStates),
  
      NewState =
          case NewMap =/= Map of
              true ->
                  apply_map(Bucket, BucketConfig, Map, NewMap),
                  State#state{bucket_config=BucketConfig, map=NewMap};
              false ->
                  State#state{bucket_config=BucketConfig}
          end,
  
      {noreply, NewState};
  
  handle_info({set_vbucket, Bucket, VBucket, _VBucketState, _CheckpointId},
              #state{bucket=Bucket, bucket_config=BucketConfig, map=Map,
                     vbucket_states=OldStates} = State) ->
      VBucketState = get_vbucket_state(Bucket, VBucket),
  
      ?log_debug("Got set_vbucket event for ~s/~b. Updated state: ~p",
                 [Bucket, VBucket, VBucketState]),
  
      NewStates = dict:store(VBucket, VBucketState, OldStates),
      NewMap = build_map(BucketConfig, NewStates),
      NewState =
          case NewMap =/= Map of
              true ->
                  apply_map(Bucket, BucketConfig, Map, NewMap),
                  State#state{vbucket_states=NewStates, map=NewMap};
              false ->
                  State#state{vbucket_states=NewStates}
          end,
  
      {noreply, NewState};
  
  handle_info({flush_all, Bucket}, #state{bucket=Bucket} = State) ->
      {noreply, apply_current_map(State)};
  
  handle_info({'EXIT', Pid, Reason}, #state{master_db_watcher=Pid} = State) ->
      {stop, Reason, State};
  
negative.code:     apply_map(Bucket, BucketConfig, undefined, Map),
      State#state{bucket_config=BucketConfig,
                  vbucket_states=VBucketStates,
                  pending_vbucket_states=VBucketStates,
                  map=Map}.
  
  interesting_ns_config_event(Bucket, {buckets, Buckets}) ->
  