Repository: couchdb-cassim Updated Branches: refs/heads/2657-fix-cassim-fabric-calls 7d9cc4717 -> ee4165a6c (forced update)
Move fabric:open_doc calls outside of gen_server COUCHDB-2657 Project: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/commit/ee4165a6 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/tree/ee4165a6 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/diff/ee4165a6 Branch: refs/heads/2657-fix-cassim-fabric-calls Commit: ee4165a6c1249b943500f91664102a2bf3dc5a88 Parents: 4c31793 Author: Russell Branca <[email protected]> Authored: Fri Apr 17 23:11:18 2015 +0000 Committer: Russell Branca <[email protected]> Committed: Mon Apr 20 21:51:22 2015 +0000 ---------------------------------------------------------------------- src/cassim_metadata_cache.erl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/ee4165a6/src/cassim_metadata_cache.erl ---------------------------------------------------------------------- diff --git a/src/cassim_metadata_cache.erl b/src/cassim_metadata_cache.erl index 1e43dce..01e7253 100644 --- a/src/cassim_metadata_cache.erl +++ b/src/cassim_metadata_cache.erl @@ -40,6 +40,10 @@ security_meta_id/1 ]). +-export([ + cache_timeout/0 +]). + -record(st, { changes_pid, @@ -59,6 +63,13 @@ metadata_db() -> config:get("couchdb", "metadata_db", "_metadata"). +cache_timeout() -> + case config:get("cassim", "cache_timeout", "5000") of + "infinity" -> infinity; + N -> list_to_integer(N) + end. + + metadata_db_exists() -> try mem3:shards(metadata_db()) of _Shards -> @@ -181,15 +192,8 @@ changes_callback({error, _}, EndSeq) -> load_meta_from_db(DbName, MetaId) -> - try fabric:open_doc(DbName, MetaId, []) of - {ok, Doc} -> - couch_doc:to_json_obj(Doc, []); - _Else -> - couch_log:warning("no record of meta ~s", [MetaId]), - undefined - catch error:database_does_not_exist -> - undefined - end. + couch_util:with_proc( + fabric, open_doc, [DbName, MetaId, []], cache_timeout()). load_meta(MetaId) ->
