bump
Dec 23, 2022
7
Level 13
Redis cache is slower than laravel file store ?
I'm just wondering if redis is so popluar why it is slower than laravel cache file store ?
Benchmark:
Caching 100 user in both stores:
Cache::store('file')->rememberForever('users', fn() => User::factory()->count(100)->make());
Cache::store('redis')->rememberForever('users', fn() => User::factory()->count(100)->make());
Getting cache key (Iterate 1000 time)

> $start = microtime(true);foreach (range(1,1000) as $item) {Cache::store('redis')->get('users');}$result = microtime(true) - $start;dump($result);
0.84473991394043 // vendor/psy/psysh/src/ExecutionLoopClosure.php(55) : eval()'d code:6
= 0.84473991394043 <----------- redis store
> $start = microtime(true);foreach (range(1,1000) as $item) {Cache::store('file')->get('users');}$result = microtime(true) - $start;dump($result);
0.72488903999329 // vendor/psy/psysh/src/ExecutionLoopClosure.php(55) : eval()'d code:6
= 0.72488903999329 <----------- file store
So i heard redis is blazing fast and leverage memory speed, Shouldn't it at least faster than file store cache in laravel?
Note than this is php redis native extension.
Please or to participate in this conversation.