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

ActiveLibrary[Caching](/categories/caching)

webfiori/cache
==============

A simple caching engine which is highly customizable.

2.0.0(8mo ago)01.7k[1 PRs](https://github.com/WebFiori/cache/pulls)MITPHPCI passing

Since Dec 8Pushed 8mo ago1 watchersCompare

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

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

WebFiori Cache
==============

[](#webfiori-cache)

A simple, secure, and highly customizable caching engine for PHP. This library provides time-based caching with built-in encryption support, making it suitable for application-level, server-level, and database-level caching scenarios.

 [![](https://github.com/WebFiori/cache/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/cache/actions) [ ![](https://camo.githubusercontent.com/d33bda35215a3218bd4dfbff482a0537a25bc04e06826770e4eb6a9b04092f6f/68747470733a2f2f636f6465636f762e696f2f67682f57656246696f72692f63616368652f6272616e63682f6d61696e2f67726170682f62616467652e737667) ](https://codecov.io/gh/WebFiori/cache) [ ![](https://camo.githubusercontent.com/95e841942d93f45a9a546581343ac348233df1cd53fda9c08d2c5547134791f7/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d57656246696f72695f6361636865266d65747269633d616c6572745f737461747573) ](https://sonarcloud.io/dashboard?id=WebFiori_cache) [ ![](https://camo.githubusercontent.com/d2f76fadf87ba8b7cab0bc7ab72929d2de6888becab7c6871c05f2ba9f02e7f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f57656246696f72692f63616368652e7376673f6c6162656c3d6c6174657374) ](https://github.com/WebFiori/cache/releases) [ ![](https://camo.githubusercontent.com/39746c1dc2b9e62f3649d315ea45c944acea400cda73c85c73e3d95e9ee296ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656266696f72692f63616368653f636f6c6f723d6c696768742d677265656e) ](https://packagist.org/packages/webfiori/cache)

Features
--------

[](#features)

- **Time-based caching** with configurable TTL (Time-to-Live)
- **Built-in encryption** for sensitive data protection
- **Multiple storage backends** (File-based included, extensible via Storage interface)
- **Static API** for backward compatibility and simple usage
- **Key prefixing** for namespace isolation
- **Comprehensive error handling** with custom exceptions

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Supported PHP Versions](#supported-php-versions)
- [Quick Start](#quick-start)
- [Usage](#usage)
    - [Basic Operations](#basic-operations)
    - [Advanced Usage](#advanced-usage)
    - [Dependency Injection](#dependency-injection)
    - [Security Configuration](#security-configuration)
    - [Custom Storage Drivers](#custom-storage-drivers)
- [API Reference](#api-reference)
- [Configuration](#configuration)
- [Security](#security)
- [License](#license)

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

[](#installation)

### Using Composer

[](#using-composer)

```
composer require webfiori/cache
```

### Manual Installation

[](#manual-installation)

1. Download the latest release from [GitHub releases](https://github.com/WebFiori/cache/releases)
2. Extract the files to your project directory
3. Include the library in your project:

```
require_once 'path/to/WebFiori/Cache/Cache.php';
// You'll also need to manually include all dependencies
require_once 'path/to/WebFiori/Cache/Storage.php';
require_once 'path/to/WebFiori/Cache/Item.php';
require_once 'path/to/WebFiori/Cache/FileStorage.php';
require_once 'path/to/WebFiori/Cache/KeyManager.php';
require_once 'path/to/WebFiori/Cache/SecurityConfig.php';
// And all exception classes...
```

**Note:** Manual installation is not recommended. Use Composer for automatic dependency management.

Supported PHP Versions
----------------------

[](#supported-php-versions)

This library requires **PHP 8.1 or higher**.

Build Status[![](https://github.com/WebFiori/cache/actions/workflows/php81.yaml/badge.svg?branch=main)](https://github.com/WebFiori/cache/actions/workflows/php81.yaml)[![](https://github.com/WebFiori/cache/actions/workflows/php82.yaml/badge.svg?branch=main)](https://github.com/WebFiori/cache/actions/workflows/php82.yaml)[![](https://github.com/WebFiori/cache/actions/workflows/php83.yaml/badge.svg?branch=main)](https://github.com/WebFiori/cache/actions/workflows/php83.yaml)[![](https://github.com/WebFiori/cache/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/cache/actions/workflows/php84.yaml)Quick Start
-----------

[](#quick-start)

```
