anchor.diff:                      [DbName, Reason]);
               {Doc} ->
                   Shards = mem3_util:build_ordered_shards(DbName, Doc),
  -                Msg = {cache_insert_change, DbName, Shards, Seq},
  +                IdleTimeout = config:get_integer(
  +                        "mem3", "writer_idle_timeout", 30000),
  +                Writer = spawn_shard_writer(DbName, Shards, IdleTimeout),
  +                ets:insert(?OPENERS, {DbName, Writer}),
  +                Msg = {cache_insert_change, DbName, Writer, Seq},
                   gen_server:cast(?MODULE, Msg),
                   [create_if_missing(mem3:name(S)) || S
                       <- Shards, mem3:node(S) =:= node()]
  
positive.code:     couch_stats:increment_counter([mem3, shard_cache, hit]),
      cache_hit(DbName),
      {noreply, St};
  handle_cast({cache_insert, DbName, Shards, UpdateSeq}, St) ->
      couch_stats:increment_counter([mem3, shard_cache, miss]),
      % This comparison correctly uses the `<` operator
      % and not `=<`. The easiest way to understand why is
      % to think of when a _dbs db doesn't change. If it used
      % `=<` it would be impossible to insert anything into
      % the cache.
      NewSt = case UpdateSeq < St#st.update_seq of
          true -> St;
          false -> cache_free(cache_insert(St, DbName, Shards))
      end,
      {noreply, NewSt};
  handle_cast({cache_remove, DbName}, St) ->
      couch_stats:increment_counter([mem3, shard_cache, eviction]),
      {noreply, cache_remove(St, DbName)};
  handle_cast({cache_insert_change, DbName, Shards, UpdateSeq}, St) ->
      Msg = {cache_insert, DbName, Shards, UpdateSeq},
      {noreply, NewSt} = handle_cast(Msg, St),
      {noreply, NewSt#st{update_seq = UpdateSeq}};
  handle_cast({cache_remove_change, DbName, UpdateSeq}, St) ->
  
negative.code:     {ok, gen_server:call(?MODULE, {set_max_size, Size}, infinity)};
  handle_config_change("mem3", "shards_db", _DbName, _, _) ->
      {ok, gen_server:call(?MODULE, shard_db_changed, infinity)};
  handle_config_change("mem3", "shard_write_timeout", Timeout, _, _) ->
      Timeout = try
          list_to_integer(Timeout)
      catch _:_ ->
          1000
      end,
      {ok, gen_server:call(?MODULE, {set_write_timeout, Timeout})};
  handle_config_change(_, _, _, _, _) ->
      {ok, nil}.
  
  