PHPackages                             hktnv/laravel-cachebench - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. hktnv/laravel-cachebench

ActiveLibrary[Caching](/categories/caching)

hktnv/laravel-cachebench
========================

A comprehensive benchmarking and profiling tool for Laravel cache drivers.

v1.0.0(1mo ago)00MITPHPPHP ^8.2

Since May 31Pushed 1mo agoCompare

[ Source](https://github.com/hktnv/laravel-cachebench)[ Packagist](https://packagist.org/packages/hktnv/laravel-cachebench)[ Docs](https://github.com/hktnv/laravel-cachebench)[ RSS](/packages/hktnv-laravel-cachebench/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel CacheBench
==================

[](#laravel-cachebench)

Laravel CacheBench is a comprehensive benchmarking and profiling tool designed to measure, compare, and analyze the performance of various Laravel cache drivers under identical, controlled workloads.

This package allows developers and DevOps engineers to make data-driven decisions when selecting a cache driver (Redis, Memcached, Database, File, Array) for their production environments.

Features
--------

[](#features)

- **Multiple Scenarios**: Organizes benchmarks into robust domains: `CrudOperations` (Writes, Reads, Deletes), `ConcurrencyPressure` (Multi-process race conditions, atomic increments, safe writes), `HotKeyPressure` (High traffic simulation on single keys), and `RealWorld` simulations.
- **Precise Metrics**: Accurately calculates Throughput (Ops/sec), Memory Usage, Latency Percentiles (Avg, Median, Min, Max, P95, P99), and tracks Data Loss / Safety issues in high-concurrency environments.
- **Beautiful HTML Reports**: Generates an interactive Chart.js HTML report to easily visualize throughput across all drivers.
- **Console Reporting**: Provides a clean, hierarchical summary tree right in your terminal with actionable diagnostic notes.
- **Fully Containerized**: Includes a Docker environment (Redis, Memcached, MySQL) for completely isolated and host-independent testing.
- **Multi-lingual Support**: Native support for English (`en`) and Turkish (`tr`).

Requirements
------------

[](#requirements)

- **PHP**: 8.2+
- **Laravel**: 11.0+
- **Docker &amp; Docker Compose** (for the isolated benchmarking environment)

Installation
------------

[](#installation)

You can install the package via composer (once published):

```
composer require Hktnv/laravel-cachebench
```

Publish the configuration and language files:

```
php artisan vendor:publish --tag=cachebench-config
php artisan vendor:publish --tag=cachebench-lang
```

Docker Environment Setup
------------------------

[](#docker-environment-setup)

To ensure consistent results, it is highly recommended to run the benchmarks inside the provided Docker environment. The environment ships with Redis, Memcached, and MySQL ready to go.

Using the included `Makefile`:

```
# Build the containers and install composer dependencies
make init

# Enter the isolated application container
make shell
```

Usage
-----

[](#usage)

Once inside the container (or your own environment), you can use the provided Artisan commands.

### 1. Run Benchmarks

[](#1-run-benchmarks)

To execute all benchmarking scenarios against all configured drivers from within the package directory, use Testbench:

```
vendor/bin/testbench cachebench:run
```

> **Important note for the `database` driver**: If you intend to run benchmarks using the `database` cache driver, you must ensure that your database contains the `cache` and `cache_locks` tables. You can create them by running:
>
> ```
> php artisan cache:table
> php artisan migrate
> ```
>
>
>
> *(If you are using Testbench directly, use `vendor/bin/testbench cache:table && vendor/bin/testbench migrate` instead).*

*(Note: If you have installed this package in an actual Laravel app, use `php artisan cachebench:run`)*

**Options:**

- `--driver=redis,memcached`: Run benchmarks only for specific drivers.
- `--scenario=Concurrency`: Run benchmarks only for specific scenarios (matches the class or namespace name like `Crud`, `Concurrency`, `HotKey`).
- `--iterations=100`: Override the default number of iterations.

### 2. Generate HTML Report

[](#2-generate-html-report)

While `cachebench:run` generates a detailed, live hierarchical tree in your console, you can also generate a persistent HTML visual report from the saved JSON results:

```
vendor/bin/testbench cachebench:report
```

This command will:

1. Output a structured summary Console Table.
2. Generate an interactive Chart.js HTML report at `storage/cachebench/report.html` to visualize and compare the throughput of all drivers.

### 3. Clean Results

[](#3-clean-results)

To safely flush all previous benchmark JSON results and the HTML report:

```
vendor/bin/testbench cachebench:clean
```

Configuration
-------------

[](#configuration)

You can customize the package behavior by editing the `config/cachebench.php` file:

- **`drivers`**: The array of cache drivers to include in the benchmark. Unavailable drivers will be skipped automatically.
- **`storage_path`**: Directory where JSON results are saved.
- **`report_path`**: Path where the final HTML report is written.

Testing
-------

[](#testing)

To run the internal unit tests (validating the mathematical accuracy of the benchmark metrics):

```
# Inside the docker container (make shell)
vendor/bin/phpunit
```

Or from the host machine:

```
make test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance89

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

54d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/267179289?v=4)[hktnv](/maintainers/hktnv)[@hktnv](https://github.com/hktnv)

---

Top Contributors

[![hktnaydn](https://avatars.githubusercontent.com/u/57008579?v=4)](https://github.com/hktnaydn "hktnaydn (1 commits)")

---

Tags

laravelperformanceprofilingrediscachememcachedbenchmark

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hktnv-laravel-cachebench/health.svg)

```
[![Health](https://phpackages.com/badges/hktnv-laravel-cachebench/health.svg)](https://phpackages.com/packages/hktnv-laravel-cachebench)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21111.6k](/packages/iazaran-smart-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
