Created
May 15, 2021 10:28
-
-
Save Cerwyn/1d981336f9519343bc2c0416a1aa34d2 to your computer and use it in GitHub Desktop.
read-write-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(); | |
for ($i = 0; $i < 100000; $i++) { | |
// Write Operation | |
Cache::store('redis')->set('redis_' . $i, 'JohnDoe'); | |
// Read operation | |
Cache::store('redis')->get('redis_' . $i); | |
} | |
Log::info(now()->diffInMilliseconds($time)); | |
Cache::store('redis')->flush(); | |
return 'Redis'; | |
}); | |
Route::get('/swoole-table', function () { | |
$time = now(); | |
for ($i = 0; $i < 100000; $i++) { | |
// Write Operation | |
Octane::table('example')->set('swoole_table_' . $i, [ | |
'name' => 'John Doe', | |
'votes' => 1000, | |
]); | |
// Read Operation | |
Octane::table('example')->get('swoole_table_' . $i); | |
} | |
Log::info(now()->diffInMilliseconds($time)); | |
return 'Swoole Table'; | |
}); | |
Route::get('/local-cache', function () { | |
$time = now(); | |
for ($i = 0; $i < 100000; $i++) { | |
// Write Operation | |
Cache::set('local_cache_' . $i, 'JohnDoe'); | |
// Read Operation | |
Cache::get('local_cache_' . $i); | |
} | |
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