Skip to content

Commit

Permalink
redis: support db selection via dbnum config
Browse files Browse the repository at this point in the history
Prefixes for keys are handy, but redis supports multiple separate dbs entirely,
via "select".  Expose that as a configuration setting.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
  • Loading branch information
karlp committed Oct 28, 2018
1 parent baa6d2f commit 67a36a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions default.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$redis_server = array( 'host' => 'localhost',
'port' => 6379,
'auth' => '',
'dbnum' => '',
'prefix' => 'emoncms');


Expand Down
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
echo "Can't connect to redis at ".$redis_server['host'].", autentication failed"; die;
}
}
if (!empty($redis_server['dbnum'])) {
$redis->select($redis_server['dbnum']);
}
} else {
$redis = false;
}
Expand Down

0 comments on commit 67a36a2

Please sign in to comment.