connect($MY_HOST, $MY_PORT, 0.5, NULL)) { echo 'FAIL'; exit(1); } $redis->set($MY_KEY, $MY_VAL); foreach ($redis->info('all') as $key => $val) { if (preg_match('/db[0-9]+/', $key)) { $database = str_replace('db', '', $key); $redis->select($database); if ($redis->get($MY_KEY) == $MY_VAL) { echo 'OK'; $redis->close(); exit(0); } } } $redis->close(); echo 'FAIL'; exit(1);