Hallo Zusammen
Hat da jemand Erfahrung mit dem Symfony Cache Psr6? Für mein Storage wollte ich den zum Testen brauchen. Jedoch war ich entäuscht da mit dem Cache die Query viel langsamer ist als ohne.
Beispiel:
Hat da jemand Erfahrung mit dem Symfony Cache Psr6? Für mein Storage wollte ich den zum Testen brauchen. Jedoch war ich entäuscht da mit dem Cache die Query viel langsamer ist als ohne.
Beispiel:
PHP-Code:
$verifier = (new Verifier())
->table('products', ['id', 'sku'], 'id')
->table('products_lg', ['product_id', 'language_id', 'title']);
$storage = new InMemoryStorage([
'products' => [
1 => ['id' => 1, 'sku' => 'rose'],
2 => ['id' => 2, 'sku' => 'sunflower'],
3 => ['id' => 3, 'sku' => 'viola'],
4 => ['id' => 4, 'sku' => 'petunia'],
5 => ['id' => 5, 'sku' => 'sanvitalia'],
6 => ['id' => 6, 'sku' => 'salvia'],
],
'products_lg' => [
['product_id' => 1, 'language_id' => 1, 'title' => 'rose'],
['product_id' => 1, 'language_id' => 2, 'title' => 'rose EN'],
['product_id' => 2, 'language_id' => 1, 'title' => 'sunflower'],
['product_id' => 2, 'language_id' => 2, 'title' => 'sunflower EN'],
['product_id' => 3, 'language_id' => 1, 'title' => 'viola'],
['product_id' => 3, 'language_id' => 2, 'title' => 'viola EN'],
]
], $verifier);
//$storage = new JsonFileStorage($verifier, __DIR__.'/storage/');
//$storage = new DatabaseStorage($verifier, $database->pdo());
$cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter();
$storage->setCache($cache);
$start = microtime(true);
for ($i = 1; $i <= 10000; $i++) {
$items = $storage
->table('products')
->select(['sku', 'title'])
->leftJoin('products_lg', function($join) use ($i) {
$join->on('id', '=', 'product_id')
//->onOr('id', '=', 'language_id');
->where('language_id', $i);
})
->where(function($query) {
$query->whereLike('title', 'farn')
->orWhereLike('desc', 'bb');
})
//->cache()
->get();
//echo '<pre>';
//print_r($items);
}
$end = (microtime(true) - $start);
echo "elapsed time: $end";
echo '<br><br>';
Kommentar