Last active
May 15, 2021 10:26
-
-
Save Cerwyn/a05f8170c875d2c0f1e698921ff245fd to your computer and use it in GitHub Desktop.
read-operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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