PHPackages                             piotrpress/cacher - 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. piotrpress/cacher

ActiveLibrary[Caching](/categories/caching)

piotrpress/cacher
=================

This library provides a simple file-based caching solution.

v1.2.0(1y ago)01113MITPHPPHP &gt;=7.4

Since Oct 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PiotrPress/cacher)[ Packagist](https://packagist.org/packages/piotrpress/cacher)[ Docs](https://github.com/PiotrPress/cacher)[ RSS](/packages/piotrpress-cacher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (3)

Cacher
======

[](#cacher)

This library provides a simple file-based caching solution.

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

[](#installation)

```
$ composer require piotrpress/cacher
```

Usage
-----

[](#usage)

```
require __DIR__ . '/vendor/autoload.php';

use PiotrPress\Cacher;

$cache = new Cacher( '.cache', 3600 );

$value = $cache->get( 'hi', function ( $arg1, $arg2 ) {
    return "$arg1 $arg2";
}, 'Hello', 'world!' );

$cache->clear( 'hi' ); // clear cache for "hi" key
$cache->clear(); // clear all cache
```

You can use `php://memory` as a file to store cache in memory, for instance, while developing or testing.

Cacher takes an expiration time in seconds as the second argument. By default, it is set to `-1`, which means the cache never expires. If the value `0` is provided, the cache will be cleared on every call.

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

[](#requirements)

Supports PHP &gt;= `7.4` version.

License
-------

[](#license)

[MIT](license.txt)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

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

Every ~161 days

Total

3

Last Release

610d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.2.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10326736?v=4)[Piotr Niewiadomski](/maintainers/PiotrPress)[@PiotrPress](https://github.com/PiotrPress)

---

Top Contributors

[![PiotrPress](https://avatars.githubusercontent.com/u/10326736?v=4)](https://github.com/PiotrPress "PiotrPress (3 commits)")

---

Tags

cachecacher

### Embed Badge

![Health badge](/badges/piotrpress-cacher/health.svg)

```
[![Health](https://phpackages.com/badges/piotrpress-cacher/health.svg)](https://phpackages.com/packages/piotrpress-cacher)
```

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[psr/cache

Common interface for caching libraries

5.2k686.9M1.3k](/packages/psr-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2512.2M6](/packages/beste-in-memory-cache)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33113.0k](/packages/anahkiasen-flatten)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23517.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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