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

ActiveLibrary[Caching](/categories/caching)

libertyphp/apcu-cache
=====================

The PSR-6 and PSR-16 cache implementation using APCu. The fastest cache for PHP.

1.0(3y ago)22.7k↓32.7%MITPHPPHP &gt;=8.1

Since Oct 30Pushed 3y agoCompare

[ Source](https://github.com/vblila/libertyphp-apcu-cache)[ Packagist](https://packagist.org/packages/libertyphp/apcu-cache)[ Docs](https://github.com/vblila/libertyphp)[ RSS](/packages/libertyphp-apcu-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

APCu Cache
==========

[](#apcu-cache)

[PSR-6](https://www.php-fig.org/psr/psr-6/) and [PSR-16](https://www.php-fig.org/psr/psr-16/) cache implementation using [APCu](https://www.php.net/manual/en/book.apcu.php). APCu is an in-memory key-value store for PHP. Keys are of type string and values can be any PHP variables.

Why APCu Cache?
===============

[](#why-apcu-cache)

Network
-------

[](#network)

APCu is non-distributed cache which you can use only in HTTP request (it doesn't work in PHP CLI). If you have a web application that doesn't run on different web servers it's better to use APCu cache, because it's the simplest cache without requests over the network.

Speed
-----

[](#speed)

APCu is faster than Memcached and Redis. Benchmark results of setting and getting of 10000 string values (Intel Core i5-8250U, DDR4 2400MHz):

```
APCu
set 0.01187s
get 0.00633s

Memcached
set 0.66142s
get 0.63786s

Redis
set 0.37687s
get 0.39227s

```

So, if your web application makes a lot of requests to the cache, it's better to have a warmed APCu cache on each worker.

Install
=======

[](#install)

```
composer require libertyphp/apcu-cache

```

Docker configuration
====================

[](#docker-configuration)

If you use php-fpm docker add this code to install APCu in PHP:

```
ARG APCU_VERSION=5.1.21

RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu
RUN echo "apc.shm_size=1024M" >> /usr/local/etc/php/php.ini
RUN echo "apc.ttl=0" >> /usr/local/etc/php/php.ini
RUN echo "apc.gc_ttl=0" >> /usr/local/etc/php/php.ini
```

Using PSR-6 implementation
==========================

[](#using--psr-6-implementation)

```
$cachePool = new ApcuCacheItemPool();
$cacheItem = (new ApcuCacheItem('u1030_rating', 98))
    ->expiresAfter(3600);

$cachePool->save($cacheItem);
```

Using PSR-16 implementation
===========================

[](#using-psr-16-implementation)

```
$cache = new ApcuCache();
$cache->set('u1030_rating', 98, 3600);
```

Copyright
=========

[](#copyright)

Copyright (c) 2022 Vladimir Lila. See LICENSE for details.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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

1297d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cb7cfdf9cb8d92d1ef870d68d98e1f307a40166893ae824bfb23c4e30414ff7c?d=identicon)[Vladimir Lila](/maintainers/Vladimir%20Lila)

---

Top Contributors

[![vblila](https://avatars.githubusercontent.com/u/16761061?v=4)](https://github.com/vblila "vblila (1 commits)")

---

Tags

cachepsr-16psr-6apculibertyphp

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/libertyphp-apcu-cache/health.svg)](https://phpackages.com/packages/libertyphp-apcu-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/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)[cache/apcu-adapter

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

173.0M22](/packages/cache-apcu-adapter)[codeigniter4/cache

PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4

1320.1k](/packages/codeigniter4-cache)

PHPackages © 2026

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