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 1w 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 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

1873d 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

[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1076.9M130](/packages/laminas-laminas-cache)[cache/adapter-common

Common classes for PSR-6 adapters

11124.4M38](/packages/cache-adapter-common)[cache/filesystem-adapter

A PSR-6 cache implementation using filesystem. This implementation supports tags

705.8M82](/packages/cache-filesystem-adapter)[cache/array-adapter

A PSR-6 cache implementation using a php array. This implementation supports tags

548.3M151](/packages/cache-array-adapter)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

523.9M27](/packages/cache-redis-adapter)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

423.1M27](/packages/cache-simple-cache-bridge)

PHPackages © 2026

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