/** * Gets a value from the hash stored at key. * If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. * * @param string $key * @param string $hashKey * * @return string The value, if the command executed successfully FALSE in case of failure * @link http://redis.io/commands/hget */ public function hGet($key, $hashKey) { try { return $this->client->hGet($key, $hashKey); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }
/** * Test deleting fields form a hash */ public function testHdel() { $this->redis->del('testHdel'); $numRemoved = $this->redis->hset('testHdel', 'field1', 'Hello'); $this->assertInternalType('int', $numRemoved); $this->assertEquals(1, $numRemoved); $this->assertEquals(1, $this->redis->hdel('testHdel', 'field1')); $this->assertEquals(0, $this->redis->hdel('testHdel', 'field1')); $this->assertEquals(1, $this->redis->hset('testHdel', 'field1', 'Hello')); $this->assertEquals(1, $this->redis->hset('testHdel', 'field2', 'Hello')); $this->assertEquals(2, $this->redis->hdel('testHdel', array('field1', 'field2'))); // make sure varargs are not supported $this->redis->hset('testHdel1', 'field1', 'abc'); $this->redis->hset('testHdel1', 'field2', 'def'); $this->assertEquals(1, $this->redis->hDel('testHdel1', 'field1', 'field2')); $this->assertEquals('def', $this->redis->hGet('testHdel1', 'field2')); $this->assertEquals(1, $this->redis->del('testHdel1')); }
/** * Gets a value from the hash stored at key. * If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. * * @param string $key * @param string $hashKey * * @return string The value, if the command executed successfully FALSE in case of failure * @link http://redis.io/commands/hget */ public function hGet($key, $hashKey) { $this->appendToLog('HGET ' . $key . ' ' . $hashKey); return $this->client->hGet($key, $hashKey); }