PHPackages                             mehr-it/php-cache - 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. mehr-it/php-cache

ActiveLibrary[Caching](/categories/caching)

mehr-it/php-cache
=================

PSR-16 simple cache implementation using PHP files as backend

1.0.0(5y ago)11.3k2MITPHPPHP &gt;=7.1

Since Apr 1Pushed 5y agoCompare

[ Source](https://github.com/mehr-it/php-cache)[ Packagist](https://packagist.org/packages/mehr-it/php-cache)[ RSS](/packages/mehr-it-php-cache/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (2)Used By (2)

PHP file cache (PSR-16)
=======================

[](#php-file-cache-psr-16)

Caching library using PHP files as backend implementing PSR-16.

Introduction
------------

[](#introduction)

Thanks to opcache, using PHP files as cache backend improves performance as it benefits from PHPs bytecode cache.

This library is aware of opcache and also invalidates opcache whenever a file is changed.

**ATTENTION:**Since opcache is not shared between different PHP SAPIs, cache data and locks are independent for each SAPI. Even clearing the cache will only invalidate the cache for the current SAPI.

This library uses [flock()](https://www.php.net/manual/en/function.flock.php) for locking.

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

[](#installation)

Use composer:

```
composer require mehr-it/php-cache

```

Usage
-----

[](#usage)

The constructor of `PhpCache` has the following arguments:

```
new PhpCache(

    // The directory to store all cache data and locks
    // in. Will be created if not existing.
    $baseDir,

    // Ensures that all created files have the given
    // permission, eg. 0660 (optional)
    $filePermission,

    // Ensures that all created directories have the
    // given permission, eg. 0770 (optional)
    $directoryPermission,

    // If set to false, keys are not checked to special
    // chars according to PSR-16. This improves
    // performance.
    $strictKeyValidation
)

```

Locks
-----

[](#locks)

In addition to the PSR-16 interface, the cache implements the ability to create named locks:

```
$cache = new PhpCache('/tmp/cache');

// create a lock
$lock = $cache->lock('my_lock', LOCK_SH);

// change locking mode, if needed
$lock->setMode(LOCK_EX);

// release lock
$lock->release();

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

1919d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44973729?v=4)[mehr.IT GmbH](/maintainers/mehr-it)[@mehr-it](https://github.com/mehr-it)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mehr-it-php-cache/health.svg)

```
[![Health](https://phpackages.com/badges/mehr-it-php-cache/health.svg)](https://phpackages.com/packages/mehr-it-php-cache)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[illuminate/contracts

The Illuminate Contracts package.

706130.3M13.3k](/packages/illuminate-contracts)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

378604.0k104](/packages/flow-php-etl)

PHPackages © 2026

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