Skip to content

Commit

Permalink
Merge pull request ChicagoBoss#167 from jgordor/master
Browse files Browse the repository at this point in the history
Option to enable/disable boss_db cache
  • Loading branch information
evanmiller committed Nov 6, 2012
2 parents b498cc6 + c9a413a commit f4978ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc-src/api-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<li><code>pgsql</code> - PostgreSQL</li>
<li><code>tyrant</code> - Tokyo Tyrant</li>
</ul></li>
<li><code>db_cache_enabled</code> - Whether to enable the cache in boss_db. Defaults to false. Requires cache_enable to be set to true.</li>
<li><code>db_shards</code> - A list of proplists with per-shard database configuration. The proplists override the above options, and should contain an additional option:
<ul>
<li><code>db_shard_models</code> - A list of models (atoms) which are stored on the shard.</li>
Expand Down
2 changes: 2 additions & 0 deletions skel/boss.config
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
%% db_password - The password used for connecting to the database (if
%% needed).
%% db_database - The name of the database to connect to (if needed).
%% db_cache_enable - Whether to enable the cache in boss_db. Defaults
%% to false. Requires cache_enable to be set to true.

{db_host, "localhost"},
{db_port, 1978},
Expand Down
8 changes: 7 additions & 1 deletion src/boss/boss_web_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ init(Config) ->
DBShards = boss_env:get_env(db_shards, []),
CacheEnable = boss_env:get_env(cache_enable, false),
IsMasterNode = boss_env:is_master_node(),
DBOptions1 = [{adapter, DBAdapter}, {cache_enable, CacheEnable},
DBCacheEnable = case {CacheEnable, boss_env:get_env(db_cache_enable, false)} of
{true, true} ->
true;
{_, _} ->
false
end,
DBOptions1 = [{adapter, DBAdapter}, {cache_enable, DBCacheEnable},
{shards, DBShards}, {is_master_node, IsMasterNode}|DBOptions],

boss_db:start(DBOptions1),
Expand Down

0 comments on commit f4978ea

Please sign in to comment.