Github user nickva commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/239#discussion_r106270691
  
    --- Diff: src/couch_lru.erl ---
    @@ -16,48 +16,57 @@
     -include_lib("couch/include/couch_db.hrl").
     
     new() ->
    -    {gb_trees:empty(), dict:new()}.
    -
    -insert(DbName, {Tree0, Dict0}) ->
    -    Lru = erlang:now(),
    -    {gb_trees:insert(Lru, DbName, Tree0), dict:store(DbName, Lru, Dict0)}.
    -
    -update(DbName, {Tree0, Dict0}) ->
    -    case dict:find(DbName, Dict0) of
    -    {ok, Old} ->
    -        New = erlang:now(),
    -        Tree = gb_trees:insert(New, DbName, gb_trees:delete(Old, Tree0)),
    -        Dict = dict:store(DbName, New, Dict0),
    -        {Tree, Dict};
    -    error ->
    -        % We closed this database before processing the update.  Ignore
    -        {Tree0, Dict0}
    +    Updates = ets:new(couch_lru_updates, [ordered_set]),
    +    Dbs = ets:new(couch_lru_dbs, [set]),
    +    {0, Updates, Dbs}.
    +
    +insert(DbName, {Count, Updates, Dbs}) ->
    +    update(DbName, {Count, Updates, Dbs}).
    +
    +update(DbName, {Count, Updates, Dbs}) ->
    --- End diff --
    
    Though thinking about it would change the logic. Notice now `Count` is a 
globally incrementing counter. This change would make so that the count is 
increment per db shard.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to