iilyak commented on issue #477: Add LRU for view groups
URL: https://github.com/apache/couchdb/pull/477#issuecomment-305650761
 
 
   I noticed that we often do something like the following:
   ```
     {ok, Pid, Mon, Args} = get_index(...),
     <something>
     couch_index_server:close(Mon)
   ```
   Did you consider implementing following helper functions
   ```
   with_index_process(Db, DDoc, ViewName, InArgs, Fun) ->
       case get_view_index_pid(Db, DDoc, ViewName, Args0) of
           {ok, Pid, Mon, Args} ->
               try
                   Fun(Pid, Args)
               after
                   ok = couch_index_server:close(Mon)
               end;
           {error, _Reason} = Error ->
               Error
       end.
   
   with_index(Module, DbName, DDocId, Fun) ->
       case get_index(Module, DbName, DDocId) of
           {ok, Pid, Mon} ->
               try
                   Fun(Pid)
               after
                   ok = couch_index_server:close(Mon)
               end;
           {error, _Reason} = Error ->
               Error
       end.
   ```
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to