PHPackages                             piedweb/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. [File &amp; Storage](/categories/file-storage)
4. /
5. piedweb/file-cache

ActiveLibrary[File &amp; Storage](/categories/file-storage)

piedweb/file-cache
==================

Permit to manage data in a file. Simple, Static and Intuitive.

0.0.5(7y ago)16.1kMITPHPPHP ~7.1

Since Jan 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/PiedWeb/FileCache)[ Packagist](https://packagist.org/packages/piedweb/file-cache)[ Docs](https://dev.piedweb.com)[ RSS](/packages/piedweb-file-cache/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

File Cache
==========

[](#file-cache)

[![Latest Version](https://camo.githubusercontent.com/793a2502ff89e17014ed0737a4c51b1e21a2d3d9e0190b5d157972880be1031f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f506965645765622f46696c6543616368652e7376673f7374796c653d666c6174266c6162656c3d72656c65617365)](https://github.com/PiedWeb/FileCache/tags)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/PiedWeb/FileCache/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/0c6710a6b17fa24eb2a2a2ea1ead76ea3d478e2c4d0cd1edd707b36feeb53cbf/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f506965645765622f46696c6543616368652f6d61737465722e7376673f7374796c653d666c6174)](https://travis-ci.org/PiedWeb/FileCache)[![Quality Score](https://camo.githubusercontent.com/d26d74a365d4707c89b084eb6bce16794d109aaf7ddb4b8c912d31c099dc3438/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f506965645765622f46696c6543616368652e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/PiedWeb/FileCache)[![Code Coverage](https://camo.githubusercontent.com/26720787d654ff7a341283de8fe7d2e47f01d0b5aa05358d3277571574507654/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f506965645765622f46696c6543616368652e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/PiedWeb/FileCache/code-structure)[![Total Downloads](https://camo.githubusercontent.com/497b287ff63b96e13b9ff46b567d6d2628d96f0beb03495648d3278c63a5d5d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706965647765622f66696c652d63616368652e7376673f7374796c653d666c6174)](https://packagist.org/packages/piedweb/file-cache)

Simple file cache library. Tested and approved. Intuitive and documented (inline and in this Readme).

Install
-------

[](#install)

Via [Packagist](https://img.shields.io/packagist/dt/piedweb/file-cache.svg?style=flat)

```
$ composer require piedweb/file-cache
```

Usage
-----

[](#usage)

```
use PiedWeb\FileCache\FileCache;

$key = 'data-2032'; // string to identify the cached data
$maxAge = 3600;     // 1 hour
$folder = './cache';
$prefix = 'tmp_';
$data = 'example data, but can be an int or an array which will be serialized'

/** Create a cache file **/
FileCache::instance()->setPrefix($folder) // Useful when you want to delete every cached data of the same type
FileCache::instance()->setCacheFolder($pregix)

FileCache::instance($folder, $prefix)->set($key, 'My string to set in a cache || But it could be an array or an object...');
FileCache::instance($folder, $prefix)->get($key, $maxAge);
FileCache::instance($folder, $prefix)->get($key, 0);  // Always valid. No expiration
FileCache::instance($folder, $prefix)->getElseCreate($key , $maxAge, function() { return ['My first data in cache']; });

/** Delete all cache files with the prefix `prfixForCacheFiles_` **/
FileCache::instance($folder, $prefix)->deleteCacheFilesByPrefix();
```

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [contributing](https://dev.piedweb.com/contributing)

Credits
-------

[](#credits)

- [PiedWeb](https://piedweb.com)
- [All Contributors](https://github.com/PiedWeb/:package_skake/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

[![Latest Version](https://camo.githubusercontent.com/793a2502ff89e17014ed0737a4c51b1e21a2d3d9e0190b5d157972880be1031f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f506965645765622f46696c6543616368652e7376673f7374796c653d666c6174266c6162656c3d72656c65617365)](https://github.com/PiedWeb/FileCache/tags)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/PiedWeb/FileCache/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/0c6710a6b17fa24eb2a2a2ea1ead76ea3d478e2c4d0cd1edd707b36feeb53cbf/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f506965645765622f46696c6543616368652f6d61737465722e7376673f7374796c653d666c6174)](https://travis-ci.org/PiedWeb/FileCache)[![Quality Score](https://camo.githubusercontent.com/d26d74a365d4707c89b084eb6bce16794d109aaf7ddb4b8c912d31c099dc3438/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f506965645765622f46696c6543616368652e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/PiedWeb/FileCache)[![Code Coverage](https://camo.githubusercontent.com/26720787d654ff7a341283de8fe7d2e47f01d0b5aa05358d3277571574507654/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f506965645765622f46696c6543616368652e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/PiedWeb/FileCache/code-structure)[![Total Downloads](https://camo.githubusercontent.com/497b287ff63b96e13b9ff46b567d6d2628d96f0beb03495648d3278c63a5d5d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706965647765622f66696c652d63616368652e7376673f7374796c653d666c6174)](https://packagist.org/packages/piedweb/file-cache)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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 ~0 days

Total

5

Last Release

2685d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/afce4cf517928a50560237f1410d5957271fd808671b2216687ecf1422adaee0?d=identicon)[Robin D.](/maintainers/Robin%20D.)

---

Tags

file cachePied Web

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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