<?php

require __DIR__ . '/../vendor/autoload.php';
console('======================================');
console('REDIS (c-client phpiredis) testing shizzle');
console('======================================');
// ############################################
$redis = \Simplon\Db\DbInstance::Redis('localhost', 1);
$redisManager = new \Simplon\Db\RedisManager($redis);
$redisManager->getRedisInstance()->dbFlush(TRUE);
$runs = 1;
$friends = 500;
// ############################################
console('+ Writing <sortedSets> WITHOUT pipeline (runs=' . $runs . ', friends=' . $friends . ')');
$summary = 0;
for ($t = 1; $t <= $runs; $t++) {
    $start = microtime(TRUE);
    for ($i = 1; $i <= $friends; $i++) {
        $response = $redisManager->getRedisInstance()->sortedSetAddValue('zset:pipe:OFF:' . $t . ':' . $i, 1, '[AID]');
    }
    $finish = microtime(TRUE);
    $timeTaken = $finish - $start;
    $summary += $timeTaken;
    console('time taken: ' . $timeTaken . ' seconds');
}
$summaryPipeOff = $summary / $runs;
console('avg. time taken: ' . $summaryPipeOff . ' seconds');
console('--------------------------------------');
// ++++++++++++++++++++++++++++++++++++++++++++
console('+ Writing <sortedSets> WITH pipeline (runs=' . $runs . ', friends=' . $friends . ')');
$summary = 0;
Exemplo n.º 2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
console('======================================');
console('REDIS (c-client phpiredis) testing shizzle');
console('======================================');
// ############################################
$redis = \Simplon\Db\DbInstance::Redis('localhost', 1);
$redisManager = new \Simplon\Db\RedisManager($redis);
$redisManager->getRedisInstance()->dbFlush(TRUE);
$runs = 3;
$sets = 1000;
// ############################################
console('+ Writing <strings> WITHOUT pipeline (runs=' . $runs . ', sets=' . $sets . ')');
$summary = 0;
for ($t = 1; $t <= $runs; $t++) {
    $start = microtime(TRUE);
    for ($i = 0; $i < $sets; $i++) {
        $response = $redisManager->getRedisInstance()->stringSet('string:pipe:OFF:' . $t . '_' . $i, 'hello world ' . $i);
    }
    $finish = microtime(TRUE);
    $timeTaken = $finish - $start;
    $summary += $timeTaken;
    console('time taken: ' . $timeTaken . ' seconds');
}
$summaryPipeOff = $summary / $runs;
console('avg. time taken: ' . $summaryPipeOff . ' seconds');
console('--------------------------------------');
// ++++++++++++++++++++++++++++++++++++++++++++
console('+ Writing <strings> WITH pipeline (runs=' . $runs . ', sets=' . $sets . ')');
$summary = 0;
Exemplo n.º 3
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$redis = \Simplon\Db\DbInstance::Redis('localhost', 2);
$redisManager = new \Simplon\Db\RedisManager($redis);
// lists
$listKey = 'list:foo';
$redisManager->getListCommandsInstance()->listPushValue($listKey, 'bar');
$data = $redisManager->getListCommandsInstance()->listGetData($listKey);
$json = json_encode($data);
var_dump(["LIST VALUE FOR KEY {$listKey}...{$json}"]);