You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2015/09/08 16:28:21 UTC
[1/2] chttpd commit: updated refs/heads/master to 6b18a8e
Repository: couchdb-chttpd
Updated Branches:
refs/heads/master 841ee1afe -> 6b18a8e6e
remove tabs
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/9496363a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/9496363a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/9496363a
Branch: refs/heads/master
Commit: 9496363a648d3e87b4189fd6d81b771788d758c8
Parents: 841ee1a
Author: Robert Newson <rn...@apache.org>
Authored: Tue Sep 8 13:49:18 2015 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Sep 8 13:49:18 2015 +0100
----------------------------------------------------------------------
src/chttpd_auth_cache.erl | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/9496363a/src/chttpd_auth_cache.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_auth_cache.erl b/src/chttpd_auth_cache.erl
index 61ee472..843be34 100644
--- a/src/chttpd_auth_cache.erl
+++ b/src/chttpd_auth_cache.erl
@@ -70,21 +70,21 @@ update_user_creds(_Req, UserDoc, _Ctx) ->
get_from_cache(UserName) ->
try ets_lru:lookup_d(?CACHE, UserName) of
- {ok, Props} ->
- couch_stats:increment_counter([couchdb, auth_cache_hits]),
- couch_log:debug("cache hit for ~s", [UserName]),
- Props;
- _ ->
- Props = load_user_from_db(UserName),
- couch_stats:increment_counter([couchdb, auth_cache_misses]),
- couch_log:debug("cache miss for ~s", [UserName]),
- ets_lru:insert(?CACHE, UserName, Props),
- Props
+ {ok, Props} ->
+ couch_stats:increment_counter([couchdb, auth_cache_hits]),
+ couch_log:debug("cache hit for ~s", [UserName]),
+ Props;
+ _ ->
+ Props = load_user_from_db(UserName),
+ couch_stats:increment_counter([couchdb, auth_cache_misses]),
+ couch_log:debug("cache miss for ~s", [UserName]),
+ ets_lru:insert(?CACHE, UserName, Props),
+ Props
catch
- error:badarg ->
- couch_stats:increment_counter([couchdb, auth_cache_misses]),
- couch_log:debug("cache miss for ~s", [UserName]),
- load_user_from_db(UserName)
+ error:badarg ->
+ couch_stats:increment_counter([couchdb, auth_cache_misses]),
+ couch_log:debug("cache miss for ~s", [UserName]),
+ load_user_from_db(UserName)
end.
%% gen_server callbacks
[2/2] chttpd commit: updated refs/heads/master to 6b18a8e
Posted by rn...@apache.org.
Don't insert nil into lru
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/6b18a8e6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/6b18a8e6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/6b18a8e6
Branch: refs/heads/master
Commit: 6b18a8e6e5cab21a1fdc88b50f76f4d8c947672a
Parents: 9496363
Author: Robert Newson <rn...@apache.org>
Authored: Tue Sep 8 13:50:31 2015 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Sep 8 13:50:31 2015 +0100
----------------------------------------------------------------------
src/chttpd_auth_cache.erl | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/6b18a8e6/src/chttpd_auth_cache.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_auth_cache.erl b/src/chttpd_auth_cache.erl
index 843be34..6e39e5a 100644
--- a/src/chttpd_auth_cache.erl
+++ b/src/chttpd_auth_cache.erl
@@ -75,11 +75,15 @@ get_from_cache(UserName) ->
couch_log:debug("cache hit for ~s", [UserName]),
Props;
_ ->
- Props = load_user_from_db(UserName),
couch_stats:increment_counter([couchdb, auth_cache_misses]),
couch_log:debug("cache miss for ~s", [UserName]),
- ets_lru:insert(?CACHE, UserName, Props),
- Props
+ case load_user_from_db(UserName) of
+ nil ->
+ nil;
+ Props ->
+ ets_lru:insert(?CACHE, UserName, Props),
+ Props
+ end
catch
error:badarg ->
couch_stats:increment_counter([couchdb, auth_cache_misses]),