Exemplo n.º 1
0
function _register_wrapper($namespace)
{
    $fs = new FileSystem(new Connector(new ConnectorConfig(), new PathTranslator($namespace)));
    Assert::true(Wrapper::register($fs));
    $context = stream_context_create(array('dir' => array('recursive' => true)));
    @rmdir('redis://', $context);
}
Exemplo n.º 2
0
 /**
  * @return void
  */
 public static function register(\Nette\DI\Container $container)
 {
     //self::getDebuggerBlueScreen()->addPanel(array(new static(), 'renderException'));
     foreach (Wrapper::getRegisteredWrappers() as $scheme => $fileSystem) {
         $panel = new static($scheme, $container);
         self::getDebuggerBar()->addPanel($panel);
     }
 }
 public function actionDefault($scheme, $dir)
 {
     if (preg_match('/^[a-z0-9]+$/i', $this->scheme)) {
         $this->scheme = $scheme;
         $this->fileSystem = Wrapper::getRegisteredWrapper($this->scheme);
     }
     $this->dir = rtrim($dir, '/') . '/';
     if (!$this->fileSystem instanceof FileSystem) {
         echo 'Unkown filesystem ' . $this->scheme . '://. Is it registered?';
         $this->terminate();
     }
 }
Exemplo n.º 4
0
<?php

namespace Sallyx\StreamWrappers;

include __DIR__ . '/../../vendor/autoload.php';
use Sallyx\StreamWrappers\Redis;
use Sallyx\StreamWrappers\Wrapper;
$fsDir = '/tmp/benchmark';
$redisDir = 'redis://';
$redisPath = 'www.sallyx.org/benchmark::';
$config = new Redis\ConnectorConfig();
$translator = new Redis\PathTranslator($redisPath);
$connector = new Redis\Connector($config, $translator);
$fs = new Redis\FileSystem($connector);
Wrapper::register($fs);
$benchmarks = [new FSBenchmark('Filesystem', $fsDir, \DIRECTORY_SEPARATOR), new FSBenchmark('Redis', $redisDir, '/')];
foreach ($benchmarks as $benchmark) {
    $benchmark->run();
    echo PHP_EOL;
}
FSBenchmark::showResults($benchmarks);
class FSBenchmark
{
    const TEST_MKDIR = 'mkdir';
    const TEST_RMDIR = 'rmdir';
    const TEST_WRITE1 = 'write_a';
    const TEST_WRITE2 = 'write_b';
    const TEST_READ = 'read';
    private static $allTests = [self::TEST_MKDIR, self::TEST_WRITE1, self::TEST_WRITE2, self::TEST_READ, self::TEST_RMDIR];
    /**
     * @var name