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

ActiveLibrary[Caching](/categories/caching)

switon/cache
============

PSR-16 cache services with Redis-backed integration for Switon Framework

v1.0.0(1mo ago)042MITPHPPHP &gt;=8.3CI passing

Since May 9Pushed 3d agoCompare

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

READMEChangelogDependencies (6)Versions (2)Used By (2)

Switon Cache Package
====================

[](#switon-cache-package)

[![CI](https://camo.githubusercontent.com/accbad4633bc4ffefa911b75a439961f91630eeaf1a882e869c3f7fd3cb975f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f63616368652f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/cache/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's PSR-16 Redis cache for batch reads and writes, prefix-scoped clearing, and cache lifecycle events.

Highlights
----------

[](#highlights)

- **PSR-16 cache:** `CacheInterface` is the main cache contract.
- **Redis-backed storage:** `SimpleCache` stores values in Redis with prefix-scoped access.
- **Batch reads and writes:** read or write multiple keys in one call.
- **Safe clearing:** `clear()` requires a prefix so it does not wipe unrelated keys.
- **Lifecycle visibility:** `CacheHit`, `CacheMiss`, and related lifecycle events can be observed.

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

[](#installation)

```
composer require switon/cache
```

Quick Start
-----------

[](#quick-start)

```
use Psr\SimpleCache\CacheInterface;
use Switon\Core\Attribute\Autowired;

class ProductService
{
    #[Autowired] protected CacheInterface $cache;

    public function getFeatured(): array
    {
        $miss = new \stdClass();
        $products = $this->cache->get('featured_products', $miss);

        if ($products === $miss) {
            $products = $this->loadFeaturedProducts();
            $this->cache->set('featured_products', $products, 1800);
        }

        return $products;
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance97

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

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

31d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (1 commits)")

---

Tags

cachepsr-16redisswitonrediscachepsr-16switon

### Embed Badge

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

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

###  Alternatives

[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1067.2M145](/packages/laminas-laminas-cache)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.3M4](/packages/sabre-cache)[cache/redis-adapter

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

574.0M27](/packages/cache-redis-adapter)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

433.3M28](/packages/cache-simple-cache-bridge)[cache/predis-adapter

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

242.6M13](/packages/cache-predis-adapter)

PHPackages © 2026

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