You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/11/05 18:11:07 UTC
[couchdb] 02/02: Use the cached security_doc and revs_limit
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch opentracing-davisp
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 4f99db47cfe17dbe588df7c53d32413af8f95cdd
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue Nov 5 12:09:53 2019 -0600
Use the cached security_doc and revs_limit
The previous change here required that we ensure that the database is up
to date but that doesn't mean we have to re-read the security_doc from
the database when we have a valid cached version.
---
src/fabric/src/fabric2_db.erl | 20 ++++++++++++--------
src/fabric/src/fabric2_fdb.erl | 2 ++
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index 4489064..668d26d 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -359,17 +359,21 @@ get_pid(#{}) ->
get_revs_limit(#{} = Db) ->
- RevsLimitBin = fabric2_fdb:transactional(Db, fun(TxDb) ->
- fabric2_fdb:get_config(TxDb, <<"revs_limit">>)
- end),
- ?bin2uint(RevsLimitBin).
+ fabric2_fdb:transactional(Db, fun(TxDb) ->
+ #{
+ revs_limit := RevsLimit
+ } = fabric2_fdb:ensure_current(TxDb),
+ RevsLimit
+ end).
get_security(#{} = Db) ->
- SecBin = fabric2_fdb:transactional(Db, fun(TxDb) ->
- fabric2_fdb:get_config(TxDb, <<"security_doc">>)
- end),
- ?JSON_DECODE(SecBin).
+ fabric2_fdb:transactional(Db, fun(TxDb) ->
+ #{
+ security_doc := Security
+ } = fabric2_fdb:ensure_current(TxDb),
+ Security
+ end).
get_update_seq(#{} = Db) ->
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index a77a1e9..2922a14 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -26,6 +26,8 @@
delete/1,
exists/1,
+ ensure_current/1,
+
get_dir/1,
list_dbs/4,