mirror of
https://github.com/predis/predis.git
synced 2026-08-17 14:25:00 +00:00
update examples
This commit is contained in:
@@ -59,7 +59,7 @@ class EventsListener implements Countable
|
||||
}
|
||||
|
||||
// Attach our callable class to the dispatcher.
|
||||
$dispatcher->attachCallback('events', ($events = new EventsListener()));
|
||||
$dispatcher->attachCallback('events', $events = new EventsListener());
|
||||
|
||||
// Attach a function to control the dispatcher loop termination with a message.
|
||||
$dispatcher->attachCallback('control', function ($payload, $dispatcher) {
|
||||
|
||||
@@ -18,7 +18,8 @@ $client = new Predis\Client($single_server);
|
||||
$client->set('library', 'predis');
|
||||
$response = $client->get('library');
|
||||
|
||||
var_export($response); echo PHP_EOL;
|
||||
var_export($response);
|
||||
echo PHP_EOL;
|
||||
/* OUTPUT: 'predis' */
|
||||
|
||||
// Redis has the MSET and MGET commands to set or get multiple keys in one go,
|
||||
@@ -33,7 +34,8 @@ $mkv = [
|
||||
$client->mset($mkv);
|
||||
$response = $client->mget(array_keys($mkv));
|
||||
|
||||
var_export($response); echo PHP_EOL;
|
||||
var_export($response);
|
||||
echo PHP_EOL;
|
||||
/* OUTPUT:
|
||||
array (
|
||||
0 => '1st user',
|
||||
@@ -49,7 +51,8 @@ $response = $client->executeRaw([
|
||||
'MGET', 'uid:0001', 'uid:0002', 'uid:0003',
|
||||
]);
|
||||
|
||||
var_export($response); echo PHP_EOL;
|
||||
var_export($response);
|
||||
echo PHP_EOL;
|
||||
/* OUTPUT:
|
||||
array (
|
||||
0 => '1st user',
|
||||
|
||||
@@ -30,7 +30,7 @@ use Predis\Replication\ReplicationStrategy;
|
||||
|
||||
class HashMultipleGetAll extends ScriptCommand
|
||||
{
|
||||
const BODY = <<<LUA
|
||||
public const BODY = <<<LUA
|
||||
local hashes = {}
|
||||
for _, key in pairs(KEYS) do
|
||||
table.insert(hashes, key)
|
||||
|
||||
@@ -26,7 +26,7 @@ require __DIR__ . '/shared.php';
|
||||
//
|
||||
|
||||
if (!interface_exists('SessionHandlerInterface')) {
|
||||
die('ATTENTION: the session handler implemented by Predis requires PHP >= 5.4.0 ' .
|
||||
exit('ATTENTION: the session handler implemented by Predis requires PHP >= 5.4.0 ' .
|
||||
"or a polyfill for SessionHandlerInterface provided by an external package.\n");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
die('Example scripts are meant to be executed locally via CLI.');
|
||||
exit('Example scripts are meant to be executed locally via CLI.');
|
||||
}
|
||||
|
||||
require __DIR__ . '/../autoload.php';
|
||||
|
||||
Reference in New Issue
Block a user