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

ActiveLibrary[Caching](/categories/caching)

solophp/cache
=============

PSR-16 compliant cache library with pluggable adapters

v1.2.0(2mo ago)014MITPHPPHP ^8.1

Since Oct 22Pushed 2mo agoCompare

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

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

PSR-16 Cache Library
====================

[](#psr-16-cache-library)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6cbb7846f9677db367bf2235fe510a69be1c9b81c19ed58b7155c43600de9e47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c6f7068702f63616368652e737667)](https://packagist.org/packages/solophp/cache)[![License](https://camo.githubusercontent.com/02f05d883a48b876f098d9291792da2723f428736f98cb249997912ecd2a2cfe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736f6c6f7068702f63616368652e737667)](https://github.com/solophp/cache/blob/main/LICENSE)[![PHP Version](https://camo.githubusercontent.com/a511446f9b36b9d1662c65986aca55c97137eb18642e318116397810cd91a587/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6c6f7068702f63616368652e737667)](https://packagist.org/packages/solophp/cache)![Coverage](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)

A flexible, PSR-16 compliant cache library with pluggable adapters for PHP 8.1+.

Features
--------

[](#features)

- Full PSR-16 (Simple Cache) compliance
- Pluggable adapter architecture
- File-based cache adapter
- Redis cache adapter
- Thread-safe file operations with `LOCK_EX`
- Automatic expiration handling
- Support for TTL as integer seconds or DateInterval

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

[](#installation)

```
composer require solophp/cache
```

For Redis support, ensure you have the Redis PHP extension installed:

```
pecl install redis
```

Usage
-----

[](#usage)

### File Cache

[](#file-cache)

```
