PHPackages                             ap-lib/persistent-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. ap-lib/persistent-cache

ActiveLibrary[Caching](/categories/caching)

ap-lib/persistent-cache
=======================

Caching of an unchanging array is typically prepared on one computer and used on another

029PHP

Since Mar 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ap-lib/persistent-cache)[ Packagist](https://packagist.org/packages/ap-lib/persistent-cache)[ RSS](/packages/ap-lib-persistent-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AP\\Cache\\Persistent
=====================

[](#apcachepersistent)

[![MIT License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Caching of an unchanging array is typically prepared on one computer and used on another.

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

[](#installation)

```
composer require ap-lib/persistent-cache
```

Features
--------

[](#features)

- Interface for saving and loading arrays
- Implementation for saving and loading arrays to a PHP file

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

[](#requirements)

- PHP 8.3 or higher

Getting Started
---------------

[](#getting-started)

```
$original_array = [
    "hello" => "world",
    "foo"   => "boo",
];

// Set up the cache object (in this case, it's just a filename)
$cache = new PhpFilePersistentCache("data.php");

// Store the array in the cache
$cache->set($original_array);

// Retrieve the array from the cache
$retrieved_array = $cache->get();

// RESULT: $retrieved_array will equal $original_array
```

**IMPORTANT**: The array can only contain primitive data types such as int, float, bool, string, and null:

```
$original_array = [
    "hello" => "world",
    "foo"   => "boo",
    "object" => new Exception("hello world"),
];

$expected_array = [
    "hello" => "world",
    "foo"   => "boo",
    "object" => null,
];

// Set up the cache object (in this case, it's just a filename)
$cache = new PhpFilePersistentCache("data.php");

// Store the array in the cache
$cache->set($original_array);

// Retrieve the array from the cache
$retrieved_array = $cache->get();

// RESULT: $retrieved_array will equal $expected_array
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1215fe5ecc9ba0ab1c730d3c992125cf6ebf460562e66be71ebae127789d465a?d=identicon)[AntonPanfilov](/maintainers/AntonPanfilov)

---

Top Contributors

[![anton-panfilov](https://avatars.githubusercontent.com/u/1083546?v=4)](https://github.com/anton-panfilov "anton-panfilov (9 commits)")

### Embed Badge

![Health badge](/badges/ap-lib-persistent-cache/health.svg)

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

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[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)

PHPackages © 2026

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