11<?php
2+ /**
3+ * Redis store for simpleSAMLphp
4+ *
5+ * This store uses the Redis document store to store data from simpleSAMLphp.
6+ * It implements the simpleSAMLphp datastore API, for easy integration with
7+ * other parts of simpleSAMLphp.
8+ *
9+ * @author Jacob Christiansen jacob@colourbox.com
10+ * @copyright 2015 Colourbox ApS
11+ * @license http://opensource.org/licenses/MIT MIT-license
12+ */
213class sspmod_redis_Store_Redis extends SimpleSAML_Store
314{
415 protected function __construct ()
516 {
6- $ config = SimpleSAML_Configuration::getConfig ('module_redis.php ' );
7- $ host = $ config ->getString ('host ' , 'localhost ' );
8- $ this ->redis = new Predis \Client ($ host );
17+ $ redisConfig = SimpleSAML_Configuration::getConfig ('module_redis.php ' );
18+ $ globalConfig = SimpleSAML_Configuration::getConfig ();
19+
20+ $ this ->redis = new Predis \Client ($ redisConfig ->getString ('host ' , 'localhost ' ));
21+ $ this ->prefix = $ redisConfig ->getString ('prefix ' , 'simpleSAMLphp ' );
922 $ this ->lifeTime = $ globalConfig ->getInteger ('session.duration ' , 28800 ); // Default 8 hours
1023 }
1124
@@ -18,7 +31,7 @@ protected function __construct()
1831 */
1932 public function get ($ type , $ key )
2033 {
21- $ redisKey = "simpleSAMLphp .$ type. $ key " ;
34+ $ redisKey = "{ $ this -> prefix } . $ type. $ key " ;
2235 $ value = $ this ->redis ->get ($ redisKey );
2336
2437 return unserialize ($ value );
@@ -37,7 +50,7 @@ public function get($type, $key)
3750 */
3851 public function set ($ type , $ key , $ value , $ expire = null )
3952 {
40- $ redisKey = "simpleSAMLphp .$ type. $ key " ;
53+ $ redisKey = "{ $ this -> prefix } . $ type. $ key " ;
4154 $ this ->redis ->set ($ redisKey , serialize ($ value ));
4255
4356 if (is_null ($ expire )) {
@@ -54,7 +67,7 @@ public function set($type, $key, $value, $expire = null)
5467 */
5568 public function delete ($ type , $ key )
5669 {
57- $ redisKey = "simpleSAMLphp .$ type. $ key " ;
70+ $ redisKey = "{ $ this -> prefix } . $ type. $ key " ;
5871 $ this ->redis ->del ($ redisKey );
5972 }
6073}
0 commit comments