PHPackages                             papimod/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. papimod/cache

ActiveLibrary[Caching](/categories/caching)

papimod/cache
=============

Module Papi

v2.1.0(7mo ago)06Apache-2.0PHPPHP &gt;=8.3.0

Since Dec 16Pushed 7mo agoCompare

[ Source](https://github.com/4uruanna/papimod-cache)[ Packagist](https://packagist.org/packages/papimod/cache)[ RSS](/packages/papimod-cache/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

Cache Papi Module
=================

[](#cache-papi-module)

[![](https://camo.githubusercontent.com/4893040bcf8e285d2895bb07a0985e48a3ddc545ff0abdeb11622706315de0f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e352d3737374242343f6c6f676f3d706870)](https://camo.githubusercontent.com/4893040bcf8e285d2895bb07a0985e48a3ddc545ff0abdeb11622706315de0f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e352d3737374242343f6c6f676f3d706870)[![](https://camo.githubusercontent.com/1a63c4971998a5b902b01583c76051a8ee8deec80235c1f6c8b5bd8e78725680/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d322d3838353633303f6c6f676f3d636f6d706f736572)](https://camo.githubusercontent.com/1a63c4971998a5b902b01583c76051a8ee8deec80235c1f6c8b5bd8e78725680/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d322d3838353633303f6c6f676f3d636f6d706f736572)

Description
-----------

[](#description)

Enable [routes](https://www.slimframework.com/docs/v4/objects/routing.html#route-expressions-caching) and [DI](https://php-di.org/doc/performances.html#setup) caching in your [papi](https://github.com/4uruanna/papi) in production.

By default you should add `.cache/` into your .gitignore file

I also recommend reading the section "[deployment in production](https://php-di.org/doc/performances.html#deployment-in-production)".

Prerequisites Modules
---------------------

[](#prerequisites-modules)

- [Dotenv](https://github.com/4uruanna/papimod-dotenv)

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

[](#configuration)

### `ENVIRONMENT` (.ENV)

[](#environment-env)

RequiredNoType`PRODUCTION`, `DEVELOPMENT`, `TEST` or `null`DescriptionEnable caching when set to `PRODUCTION`Default`null`### `CACHE_DIRECTORY` (.ENV)

[](#cache_directory-env)

RequiredNoTypestringDescriptionCache directory pathDefault`{{project_directory}}/.cache`### `CACHE_TIMEOUT` (.ENV)

[](#cache_timeout-env)

RequiredNoTypeIntDescriptionTime in seconds between cache refreshesDefault86400API
---

[](#api)

- [(class) CacheService](./source/CacheService.php)

Usage
-----

[](#usage)

You can add the following options to your `.env` file:

```
ENVIRONMENT=PRODUCTION
CACHE_DIRECTORY=tmp
CACHE_TIMEOUT=900

```

Import the module when creating your application:

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

use Papi\PapiBuilder;
use Papimod\Dotenv\DotEnvModule;
use Papimod\Cache\CacheModule;
use function DI\create;

define("PAPI_DOTENV_DIRECTORY", __DIR__); # Optionnal
define("PAPI_DOTENV_FILE", ".env"); # Optionnal

$builder = new PapiBuilder();

$builder->setModule(
        DotEnvModule::class,
        CacheModule::class
    )
    ->build()
    ->run();
```

Use the dedicated service anywhere:

```
final class MyService
{
    private readonly CacheService $cache_service;

    public function __construct(CacheService $cache_service)
    {
        $this->cache_service = $cache_service;
    }

    public increment(): string
    {
        $foo = $this->cache_service->get('foo');

        if($foo !== null) {
            $foo++
        } else {
            $foo = 1;
        }

        $this->cache_service->set('foo', $foo, 120);
    }
}
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance62

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

238d ago

### Community

Maintainers

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

---

Top Contributors

[![4uruanna](https://avatars.githubusercontent.com/u/179627698?v=4)](https://github.com/4uruanna "4uruanna (19 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/papimod-cache/health.svg)

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

###  Alternatives

[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.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

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