summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriilyak <iilyak@users.noreply.github.com>2018-10-18 12:13:16 -0700
committerGitHub <noreply@github.com>2018-10-18 12:13:16 -0700
commite8410d3b1a37cc117abfc22e51e8c7ba93fc19ba (patch)
treed4307fdf0fcbaef48805a5c3ab4dc5579bca7448
parent4a76ccbd51786218f8bf20b888bbb23e40a019db (diff)
parent2301cf35b8f08659fcdfcebd260d628b067abefd (diff)
downloadcouchdb-e8410d3b1a37cc117abfc22e51e8c7ba93fc19ba.tar.gz
Merge pull request #1655 from cloudant/fix-lru_opts
Fix ets_lru configuration in chttpd application
-rw-r--r--src/chttpd/src/chttpd_sup.erl33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/chttpd/src/chttpd_sup.erl b/src/chttpd/src/chttpd_sup.erl
index fe84b67eb..369248ea6 100644
--- a/src/chttpd/src/chttpd_sup.erl
+++ b/src/chttpd/src/chttpd_sup.erl
@@ -80,21 +80,18 @@ maybe_replace(Key, Value, Settings) ->
end.
lru_opts() ->
- case config:get("chttpd_auth_cache", "max_objects") of
- MxObjs when is_integer(MxObjs), MxObjs > 0 ->
- [{max_objects, MxObjs}];
- _ ->
- []
- end ++
- case config:get("chttpd_auth_cache", "max_size", "104857600") of
- MxSize when is_integer(MxSize), MxSize > 0 ->
- [{max_size, MxSize}];
- _ ->
- []
- end ++
- case config:get("chttpd_auth_cache", "max_lifetime", "600000") of
- MxLT when is_integer(MxLT), MxLT > 0 ->
- [{max_lifetime, MxLT}];
- _ ->
- []
- end.
+ lists:foldl(fun append_if_set/2, [], [
+ {max_objects, config:get_integer("chttpd_auth_cache", "max_objects", 0)},
+ {max_size, config:get_integer("chttpd_auth_cache", "max_size", 104857600)},
+ {max_lifetime, config:get_integer("chttpd_auth_cache", "max_lifetime", 600000)}
+ ]).
+
+append_if_set({Key, Value}, Opts) when Value > 0 ->
+ [{Key, Value} | Opts];
+append_if_set({Key, 0}, Opts) ->
+ Opts;
+append_if_set({Key, Value}, Opts) ->
+ couch_log:error(
+ "The value for `~s` should be string convertable "
+ "to integer which is >= 0 (got `~p`)", [Key, Value]),
+ Opts.