PHPackages                             alirezaashrafi/php-file-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. alirezaashrafi/php-file-cache

ActiveLibrary[Caching](/categories/caching)

alirezaashrafi/php-file-cache
=============================

Fast key value caching system based on file system (without any databases like Redis or Memcache)

v2.0(4y ago)08MITPHPPHP &gt;=5.3.0

Since Mar 18Pushed 4y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (0)

php-file-cache
==============

[](#php-file-cache)

Fast key value caching system based on file system (without any databases like Redis or Memcache)

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

[](#installation)

This project using composer.

```
$ composer require alirezaashrafi/php-file-cache

```

Usage
-----

[](#usage)

After installation, you can use 'Cache' class in your project

```
use AlirezaAshrafi\Cache;
```

If class with 'Cache' name already exists you can use AS for rename included class

```
use AlirezaAshrafi\Cache as FileCache;
```

- Initialization parameters are directory and file name
- First parameter is absolute path of cache directory
- Second parameter is the file you want to save results

```
$directory = __DIR__ . '/cache-dir';
$file = 'products';

$cache = new Cache($directory , $file);

// OR

$cache = new Cache(__DIR__ . '/cache-dir' , 'products');
```

- Directory hierarchy (path/cache-dir/products)

#### Set

[](#set)

```
$cache->set("product-1-name", "Iphone 13");
$cache->set("product-1-description", "Iphone 13 pro max 256G");
```

#### Get

[](#get)

```
$product_name = $cache->get("product-1-name", "default value"); // "Iphone 13"
$product_name = $cache->get("product-2-name", "default value"); // "default value"
```

- If cache exists it will return the value ("Iphone 13 pro max")
- Else if cache not exists default value will return ("default value")

#### Has

[](#has)

```
$cache->has("product-1-name"); // TRUE
$cache->has("product-2-name"); // FALSE
```

- Has function checks the existence of cache in file and memory
- True or False are return values of has function

#### Delete

[](#delete)

```
$cache->delete("product-1-description"); // TRUE
```

#### Get ALL

[](#get-all)

```
$cache->getAll();
```

#### Purge (Delete ALL)

[](#purge-delete-all)

```
$cache->purgeAll();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Every ~2 days

Total

2

Last Release

1510d ago

Major Versions

v0.1 → v2.02022-03-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e0bad9aff661c1ecbd31a3c2fade0b4d85317431ad0ba471a089e82da7e401f?d=identicon)[alirezaashrafi](/maintainers/alirezaashrafi)

---

Top Contributors

[![alirezaashrafi](https://avatars.githubusercontent.com/u/25801966?v=4)](https://github.com/alirezaashrafi "alirezaashrafi (7 commits)")

---

Tags

cachefile cacheKey valuekey value cache

### Embed Badge

![Health badge](/badges/alirezaashrafi-php-file-cache/health.svg)

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

###  Alternatives

[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15191.3k7](/packages/rapidwebltd-rw-file-cache)[bnomei/kirby3-php-cachedriver

PHP based Cache-Driver

112.6k](/packages/bnomei-kirby3-php-cachedriver)[bnomei/kirby3-redis-cachedriver

Advanced Redis cache-driver with in-memory store, transactions and preloading

101.7k](/packages/bnomei-kirby3-redis-cachedriver)

PHPackages © 2026

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