Skip to content

Instantly share code, notes, and snippets.

@Cerwyn
Created May 15, 2021 10:31
Show Gist options
  • Save Cerwyn/31220ea1378bc682c4acfcf62e49027f to your computer and use it in GitHub Desktop.
Save Cerwyn/31220ea1378bc682c4acfcf62e49027f to your computer and use it in GitHub Desktop.
write-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();
for ($i = 0; $i < 100000; $i++) {
// Write Operation
Cache::store('redis')->set('redis_' . $i, 'JohnDoe');
}
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,
]);
}
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');
}
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