Advanced PSR-16 compliant multi-layer caching library

Installs: 71

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/jardisadapter/cache

1.0.0 2026-02-25 17:34 UTC

README

Build Status License: PolyForm NC PHP Version PHPStan Level PSR-4 PSR-12 PSR-16 Coverage

Part of the Jardis Ecosystem — A modular DDD framework for PHP

A powerful, PSR-16 compliant multi-layer caching library for PHP 8.2+ that provides blazing-fast performance through intelligent cache layering and automatic write-through propagation. Chain multiple cache backends (Memory, APCu, Redis, Database) with automatic fallback and write-through population.

Features

  • Multi-Layer Caching — Chain of Responsibility pattern for cascading cache lookups (L1 → L2 → L3)
  • Automatic Write-Through — Cache miss in L1? Automatically populated from L2/L3
  • Named Layer Access — Target specific cache layers via layer() for selective operations
  • PSR-16 Compliant — Standard Simple Cache interface, works with any PSR-16 tool
  • Multiple Backends — Memory, APCu, Redis, and Database adapters included
  • Namespace Isolation — Prevent key collisions with namespace prefixes
  • TTL Support — Seconds or DateInterval for flexible expiration
  • Zero Dependencies — Only PSR interfaces required

Installation

composer require jardisadapter/cache

Quick Start

use JardisAdapter\Cache\Cache;
use JardisAdapter\Cache\Adapter\CacheMemory;
use JardisAdapter\Cache\Adapter\CacheRedis;

// Multi-layer cache with named layers (PHP 8 named arguments)
$cache = new Cache(
    memory: new CacheMemory(),          // L1: In-memory (fastest)
    redis:  new CacheRedis($redis)      // L2: Redis (persistent)
);

// PSR-16: operates on all layers
$cache->set('user:123', $userData, 3600);
$user = $cache->get('user:123');
$cache->delete('user:123');

// Targeted: operate on a specific layer only
$cache->layer(CacheRedis::LAYER_NAME)->set('session:abc', $data, 1800);
$cache->layer(CacheMemory::LAYER_NAME)->delete('temp:key');

Documentation

Full documentation, examples and API reference:

jardis.io/docs/adapter/cache

Jardis Ecosystem

This package is part of the Jardis Ecosystem — a collection of modular, high-quality PHP packages designed for Domain-Driven Design.

Category Packages
Core Domain, Kernel, Data, Workflow
Adapter Cache, Logger, Messaging, DbConnection
Support DotEnv, DbQuery, Validation, Factory, ClassVersion
Tools Builder, DbSchema

Explore all packages

License

This package is licensed under the PolyForm Noncommercial License 1.0.0.

For commercial use, see COMMERCIAL.md.

Jardis Ecosystem by Headgent Development