Skip to content

Instantly share code, notes, and snippets.

@Cerwyn
Last active May 15, 2021 10:26
Show Gist options
  • Save Cerwyn/a05f8170c875d2c0f1e698921ff245fd to your computer and use it in GitHub Desktop.
Save Cerwyn/a05f8170c875d2c0f1e698921ff245fd to your computer and use it in GitHub Desktop.
read-operations
<?php
use Laravel\Octane\Facades\Octane;
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
Route::get('/redis', function () {
$time = now();
Cache::store('redis')->set('redis', 'JohnDoe');
for ($i = 0; $i < 100000; $i++) {
// Read operation
Cache::store('redis')->get('redis');
}
Log::info(now()->diffInMilliseconds($time));
Cache::store('redis')->flush();
return 'Redis';
});
Route::get('/swoole-table', function () {
$time = now();
Octane::table('example')->set('swoole_table', [
'name' => 'John Doe',
'votes' => 1000,
]);
for ($i = 0; $i < 100000; $i++) {
// Read Operation
Octane::table('example')->get('swoole_table');
}
Log::info(now()->diffInMilliseconds($time));
return 'Swoole Table';
});
Route::get('/local-cache', function () {
$time = now();
Cache::set('local_cache', 'JohnDoe');
for ($i = 0; $i < 100000; $i++) {
// Read Operation
Cache::get('local_cache');
}
Log::info(now()->diffInMilliseconds($time));
Cache::flush();
return 'Local Cache';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment