switon/cache

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

Maintainers

Package info

github.com/switon-php/cache

Documentation

pkg:composer/switon/cache

Statistics

Installs: 4

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-09 16:37 UTC

This package is auto-updated.

Last update: 2026-05-10 02:56:47 UTC


README

PSR-16 cache services and Redis-backed cache integration for Switon Framework.

Installation

composer require switon/cache

Requirements: PHP 8.3+

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: https://docs.switon.dev/latest/cache

License

MIT.