From e00b99dc8d50029dd4f6c9fff61fc34a8e6a7bb4 Mon Sep 17 00:00:00 2001 From: Jacob Christiansen Date: Fri, 27 Mar 2015 13:30:02 +0100 Subject: [PATCH] Return null on key not found --- lib/Store/Redis.php | 4 ++++ test/Store/RedisTest.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Store/Redis.php b/lib/Store/Redis.php index 05bcf5d..4435cea 100644 --- a/lib/Store/Redis.php +++ b/lib/Store/Redis.php @@ -37,6 +37,10 @@ public function get($type, $key) $redisKey = "{$this->prefix}.$type.$key"; $value = $this->redis->get($redisKey); + if (is_null($value)) { + return null; + } + return unserialize($value); } diff --git a/test/Store/RedisTest.php b/test/Store/RedisTest.php index 51317ab..7bff05c 100644 --- a/test/Store/RedisTest.php +++ b/test/Store/RedisTest.php @@ -126,7 +126,7 @@ public function testGetNonExistingKey() $res = $store->get('test', 'nokey'); $this->assertEquals('simpleSAMLphp.test.nokey', Predis\Client::$getKey); - $this->assertFalse($res); + $this->assertNull($res); } public function testDeleteKey()