PHPackages                             onstuimig/cachetool-library - 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. onstuimig/cachetool-library

ActiveLibrary[Caching](/categories/caching)

onstuimig/cachetool-library
===========================

Manage your OPcache &amp; APCu cache

10.0.0(8mo ago)0140MITPHPPHP &gt;=8.1.0CI passing

Since Aug 20Pushed 8mo agoCompare

[ Source](https://github.com/onstuimig/cachetool-library)[ Packagist](https://packagist.org/packages/onstuimig/cachetool-library)[ RSS](/packages/onstuimig-cachetool-library/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

CacheTool Library - Manage OPcache &amp; APCu cache
===================================================

[](#cachetool-library---manage-opcache--apcu-cache)

[![Coverage Status](https://camo.githubusercontent.com/abb011ed2c84179d4aa419253a29476104150b3fcaee997e2203cd9a80125b59/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f6f6e737475696d69672f6361636865746f6f6c2d6c6962726172792f6d61696e3f7374796c653d666c61742d737175617265)](https://coveralls.io/github/onstuimig/cachetool-library?branch=main)[![Version](https://camo.githubusercontent.com/adb886f2a226613a35426736e6eff9bfcde6e02c26aa967d8fa4192735276342/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6f6e737475696d69672f6361636865746f6f6c2d6c6962726172793f736f72743d73656d766572267374796c653d666c61742d737175617265)](https://github.com/onstuimig/cachetool-library/releases)[![Downloads](https://camo.githubusercontent.com/f8a3caae1419acc36476a861723e8b139ef54c8551a30f8e65c17b701ab1d78e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e737475696d69672f6361636865746f6f6c2d6c6962726172793f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onstuimig/cachetool-library)

CacheTool Library allows you to work with APCu, OPcache, and the file status cache. It will connect to a FastCGI server (like PHP-FPM) and operate on its cache.

> This is a library-only fork of [gordalina/cachetool](https://github.com/gordalina/cachetool)

Why is this useful?

- Maybe you want to clear the bytecode cache without reloading php-fpm or using a web endpoint
- Maybe you want to have a cron which deals with cache invalidation
- Maybe you want to see some statistics right from PHP
- And many more...

Note that, unlike APCu and Opcache, the file status cache is per-process rather than stored in shared memory. This means that running `stat:clear` against PHP-FPM will only affect whichever FPM worker responds to the request, not the whole pool. [Julien Pauli has written a post](http://blog.jpauli.tech/2014-06-30-realpath-cache-html/) with more details on how the file status cache operates.

```

## Usage

Add it as a dependency

```sh
composer require onstuimig/cachetool-library

```

Create instance

```
use CacheTool\Adapter\FastCGI;
use CacheTool\CacheTool;

$adapter = new FastCGI('127.0.0.1:9000');
$cache = CacheTool::factory($adapter, '/tmp');
```

You can use `apcu` and `opcache` functions

```
$cache->apcu_clear_cache();
$cache->opcache_reset();
```

Proxies
-------

[](#proxies)

CacheTool depends on `Proxies` to provide functionality, by default when creating a CacheTool instance from the factory all proxies are enabled [`ApcuProxy`](https://github.com/onstuimig/cachetool-library/blob/main/src/Proxy/ApcuProxy.php), [`OpcacheProxy`](https://github.com/onstuimig/cachetool-library/blob/main/src/Proxy/OpcacheProxy.php) and [`PhpProxy`](https://github.com/onstuimig/cachetool-library/blob/main/src/Proxy/PhpProxy.php), you can customize it or extend to your will like the example below:

```
use CacheTool\Adapter\FastCGI;
use CacheTool\CacheTool;
use CacheTool\Proxy;

$adapter = new FastCGI('/var/run/php-fpm.sock');
$cache = new CacheTool();
$cache->setAdapter($adapter);
$cache->addProxy(new Proxy\ApcuProxy());
$cache->addProxy(new Proxy\PhpProxy());
```

Testing
-------

[](#testing)

After running `composer install`, run `./vendor/bin/phpunit`

### Troubleshooting test failures

[](#troubleshooting-test-failures)

#### sslip.io

[](#sslipio)

Tests in `tests/Adapter/Http/FileGetContentsTest` and `tests/Adapter/Http/SymfonyHttpClientTest` rely on [sslip.io](https://sslip.io/) to resolve hostnames containing an IP to the IP contained. For this to work a nameserver from sslip.io needs to be in the DNS servers configured on the host which runs those tests, otherwise hostnames like `_.127.0.0.1.sslip.io` used for testing will not resolve. The IP addresses for the DNS servers can be found on [sslip.io](https://sslip.io), how to configure them depends on the system used to run the tests.

Version Compatibility
---------------------

[](#version-compatibility)

CacheTool LibraryPHP`9.x``>=8.1`License
-------

[](#license)

CacheTool is licensed under the MIT License - see the [LICENSE](LICENSE) for details

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance61

Regular maintenance activity

Popularity12

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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

Every ~213 days

Total

3

Last Release

246d ago

Major Versions

9.2.1 → 10.0.02025-10-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2ba69e8f2b74e81038a89f16ef8b90e71288f339b048b17b41da594e4ef25ce?d=identicon)[Onstuimig](/maintainers/Onstuimig)

---

Top Contributors

[![gordalina](https://avatars.githubusercontent.com/u/787913?v=4)](https://github.com/gordalina "gordalina (423 commits)")[![jdufresne](https://avatars.githubusercontent.com/u/347634?v=4)](https://github.com/jdufresne "jdufresne (19 commits)")[![sideshowcoder](https://avatars.githubusercontent.com/u/108488?v=4)](https://github.com/sideshowcoder "sideshowcoder (9 commits)")[![fyrye](https://avatars.githubusercontent.com/u/302306?v=4)](https://github.com/fyrye "fyrye (6 commits)")[![dritter](https://avatars.githubusercontent.com/u/1544760?v=4)](https://github.com/dritter "dritter (6 commits)")[![JeroenJRP](https://avatars.githubusercontent.com/u/15321825?v=4)](https://github.com/JeroenJRP "JeroenJRP (4 commits)")[![MasonM](https://avatars.githubusercontent.com/u/651224?v=4)](https://github.com/MasonM "MasonM (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![jrmbrgs](https://avatars.githubusercontent.com/u/1610846?v=4)](https://github.com/jrmbrgs "jrmbrgs (3 commits)")[![francoisfreitag](https://avatars.githubusercontent.com/u/2758243?v=4)](https://github.com/francoisfreitag "francoisfreitag (3 commits)")[![bangpound](https://avatars.githubusercontent.com/u/6731?v=4)](https://github.com/bangpound "bangpound (2 commits)")[![barasimumatik](https://avatars.githubusercontent.com/u/48050627?v=4)](https://github.com/barasimumatik "barasimumatik (2 commits)")[![brandung-sjorek](https://avatars.githubusercontent.com/u/38257959?v=4)](https://github.com/brandung-sjorek "brandung-sjorek (2 commits)")[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (2 commits)")[![rusnak](https://avatars.githubusercontent.com/u/1324805?v=4)](https://github.com/rusnak "rusnak (2 commits)")[![sebastien-fauvel](https://avatars.githubusercontent.com/u/4215521?v=4)](https://github.com/sebastien-fauvel "sebastien-fauvel (2 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![duxthefux](https://avatars.githubusercontent.com/u/6758162?v=4)](https://github.com/duxthefux "duxthefux (1 commits)")[![mbrodala](https://avatars.githubusercontent.com/u/5037116?v=4)](https://github.com/mbrodala "mbrodala (1 commits)")[![SVillette](https://avatars.githubusercontent.com/u/17042730?v=4)](https://github.com/SVillette "SVillette (1 commits)")

---

Tags

cachefastcgiapcuopcodeOpcachefpm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/onstuimig-cachetool-library/health.svg)

```
[![Health](https://phpackages.com/badges/onstuimig-cachetool-library/health.svg)](https://phpackages.com/packages/onstuimig-cachetool-library)
```

###  Alternatives

[gordalina/cachetool

Manage your OPcache &amp; APCu cache through the CLI

1.8k3.8M5](/packages/gordalina-cachetool)[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M514](/packages/shopware-core)

PHPackages © 2026

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