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(4mo ago)06Apache-2.0PHPPHP &gt;=8.3.0

Since Dec 16Pushed 4mo agoCompare

[ Source](https://github.com/4uruanna/papimod-cache)[ Packagist](https://packagist.org/packages/papimod/cache)[ RSS](/packages/papimod-cache/feed)WikiDiscussions main Synced 1mo 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

36

—

LowBetter than 82% of packages

Maintenance74

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

147d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22fd4dcec379ce472b56c0f51528fa61ce156e5063756abcce648361770fc839?d=identicon)[4uruanna](/maintainers/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

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)

PHPackages © 2026

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