anchor.diff:  %%%===================================================================
   %%% Internal functions
   %%%===================================================================
  +do_get_positions(State = #state{cache = Cache}) ->
  +  {reply, {ok, ets:tab2list(Cache)}, State}.
  +
  +do_get_last_position(State = #state{cache = Cache}, SearchPositionId, SearchDeviceId) ->
  +  Match = ets:fun2ms(fun(Position = #position{id = Id, deviceId = DeviceId}) when (Id =:= SearchPositionId) and (DeviceId =:= SearchDeviceId) -> Position end),
  +  {reply, {ok, ets:select(Cache, Match)}, State}.
  +
  +do_create_position(State = #state{cache = Cache}, PositionModel) ->
  +  case em_storage:create_position(PositionModel) of
  +    {ok, Position} ->
  +      case ets:insert(Cache, Position) of
  +        true ->
  +          {reply, {ok, Position}, State};
  +        false ->
  +          {reply, {error, <<"Error sync in positions cache">>}, State}
  +      end;
  +    Reason ->
  +      {reply, Reason, State}
  +  end.
  
positive.code: 
  %% API
  -export([start_link/0]).
  
  %% gen_server callbacks
  -export([init/1,
  
negative.code:   {noreply, NewState :: #state{}, timeout() | hibernate} |
    {stop, Reason :: term(), Reply :: term(), NewState :: #state{}} |
    {stop, Reason :: term(), NewState :: #state{}}).
  handle_call({get}, _From, State) ->
    do_get_positions(State);
  handle_call({get, PositionId, DeviceId}, _From, State) ->
    do_get_last_position(State, PositionId, DeviceId);
  handle_call({create, Position}, _From, State) ->
    do_create_position(State, Position);
  handle_call(_Request, _From, State) ->
    {reply, ok, State}.
  
  