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

ActiveLibrary[Caching](/categories/caching)

beauty-framework/cache
======================

Beauty Cache

1.0.2(11mo ago)0153MITPHPPHP &gt;=8.1

Since Jun 10Pushed 11mo agoCompare

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

READMEChangelog (2)Dependencies (5)Versions (3)Used By (3)

Beauty Cache
============

[](#beauty-cache)

A simple, PSR-16-compatible cache component for the Beauty Framework. Supports multiple cache backends (drivers), including in-memory array cache, Redis (via ext-redis), file cache, and RoadRunner key-value plugin.

Features
--------

[](#features)

- ✅ PSR-16 `CacheInterface` compliant
- ✅ Simple driver system
- ✅ Lazy connection resolution via `CacheRegistry`
- ✅ Easy to extend with custom drivers
- ✅ Clean, typed API

Supported Drivers
-----------------

[](#supported-drivers)

Driver IDDescriptionTTL SupportFlush SupportRequirements`array`In-memory array cache❌✅none`file`File-based cache storage✅✅none`redis`Redis-based cache via ext-redis✅✅PHP extension `redis``roadrunner-kv`RoadRunner KeyValue plugin (gRPC bridge)⚠️ Partial✅RoadRunner + plugin`memory`LRU cache in memory❌❌LRU cache> ℹ️ `memcached` is not supported out of the box but can be added as a custom driver (see example below).

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

[](#installation)

```
composer require beauty-framework/cache
```

Configuration Example
---------------------

[](#configuration-example)

```
use Beauty\Cache\CacheRegistry;
use Beauty\Cache\CacheFactory;
use Beauty\Cache\Driver\ArrayCacheDriver;
use Beauty\Cache\Driver\FileCacheDriver;
use Beauty\Cache\Driver\RedisCacheDriver;
use Beauty\Cache\Driver\KVCacheDriver;

$registry = new CacheRegistry(
    caches: [
        'redis' => ['driver' => 'redis', 'host' => '127.0.0.1', 'port' => 6379],
        'file' => ['driver' => 'file', 'directory' => __DIR__.'/storage/cache'],
        'kv' => ['driver' => 'roadrunner-kv', 'store' => 'memory']
    ],
    factory: new CacheFactory([
        new ArrayCacheDriver(),
        new FileCacheDriver(),
        new RedisCacheDriver(),
        new KVCacheDriver(),
    ]),
    default: 'redis'
);

$cache = $registry->get();
$cache->set('foo', 'bar');
echo $cache->get('foo'); // bar
```

Custom Driver Example: Memcached
--------------------------------

[](#custom-driver-example-memcached)

```
use Memcached;
use Psr\SimpleCache\CacheInterface;

class Memcache implements CacheInterface
{
    public function __construct(private Memcached $memcached) {}

    public function get(string $key, mixed $default = null): mixed {
        $value = $this->memcached->get($key);
        return $value === false ? $default : $value;
    }

    public function set(string $key, mixed $value, $ttl = null): bool {
        return $this->memcached->set($key, $value, $ttl ?? 0);
    }

    public function delete(string $key): bool {
        return $this->memcached->delete($key);
    }

    public function clear(): bool {
        return $this->memcached->flush();
    }

    public function getMultiple(iterable $keys, mixed $default = null): iterable {
        $results = [];
        foreach ($keys as $key) {
            $results[$key] = $this->get($key, $default);
        }
        return $results;
    }
    public function setMultiple(iterable $values, $ttl = null): bool {
        foreach ($values as $key => $value) {
            if (!$this->set($key, $value, $ttl)) return false;
        }
        return true;
    }

    public function deleteMultiple(iterable $keys): bool {
        foreach ($keys as $key) {
            if (!$this->delete($key)) return false;
        }
        return true;
    }

    public function has(string $key): bool {
        return $this->memcached->get($key) !== false;
    }
}
```

```
use Beauty\Cache\Driver\CacheDriverInterface;
use Psr\SimpleCache\CacheInterface;
use Memcached;

class MemcachedCacheDriver implements CacheDriverInterface
{
    public function supports(string $driver): bool
    {
        return $driver === 'memcached';
    }

    public function make(array $config): CacheInterface
    {
        $memcached = new Memcached();
        $memcached->addServer($config['host'] ?? '127.0.0.1', $config['port'] ?? 11211);

        return new
}
```

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance51

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

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 ~0 days

Total

2

Last Release

342d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/068f8c26f06f513a9c38d2a01c4d90a85eae1125a5b9d14eae7059715be860e4?d=identicon)[m1n64](/maintainers/m1n64)

---

Top Contributors

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

---

Tags

cachebeauty

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

Common classes for PSR-6 adapters

11124.4M38](/packages/cache-adapter-common)[cache/cache

Library of all the php-cache adapters

2712.7M22](/packages/cache-cache)[cache/filesystem-adapter

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

705.8M82](/packages/cache-filesystem-adapter)[cache/array-adapter

A PSR-6 cache implementation using a php array. This implementation supports tags

548.3M151](/packages/cache-array-adapter)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

523.9M27](/packages/cache-redis-adapter)

PHPackages © 2026

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