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

ActiveLibrary[Caching](/categories/caching)

kodus/file-cache
================

Minimal PSR-16 cache-implementation

2.1.0(1y ago)36461.0k↓38.2%6[5 issues](https://github.com/kodus/file-cache/issues)[3 PRs](https://github.com/kodus/file-cache/pulls)3MITPHPPHP &gt;= 8.0

Since Nov 28Pushed 1y ago3 watchersCompare

[ Source](https://github.com/kodus/file-cache)[ Packagist](https://packagist.org/packages/kodus/file-cache)[ RSS](/packages/kodus-file-cache/feed)WikiDiscussions master Synced 2d ago

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

kodus/file-cache
================

[](#kodusfile-cache)

[![PHP Version](https://camo.githubusercontent.com/487804500a039aee09e5d93e41b745b4cd68dcc0fdf801e67d26d30b93f83358/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e302532422d626c75652e737667)](https://packagist.org/packages/kodus/file-cache)[![Build Status](https://camo.githubusercontent.com/8630184688f25e4bdcfc81c035af64bcca66be65a74b1916f186ee63e20033d5/68747470733a2f2f7472617669732d63692e6f72672f6b6f6475732f66696c652d63616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kodus/file-cache)[![Code Coverage](https://camo.githubusercontent.com/2362f24fa192597491366a44d7cbe6a2546ba8d395375ca3815b438cd4cf4466/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6475732f66696c652d63616368652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodus/file-cache/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5de491d4d74f0a9f060df2ebd60048c9a81cc9ee3012849dd51ad42aa3b385cb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6475732f66696c652d63616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodus/file-cache/?branch=master)

This library provides a minimal [PSR-16](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md)cache-implementation backed by simple file-system storage.

This can be used to provide working, lightweight bootstrapping when you want to ship a project that works out of the box, but doesn't depend on an [awesome, full-blown caching-framework](http://www.scrapbook.cash/).

Strategy
--------

[](#strategy)

Files are stored in a specified cache-folder, with two levels of sub-folders to avoid file-system limitations on the number of files per folder. (This will probably work okay for entry-numbers in the tens of thousands - if you're storing cache-entries in the millions, you should not be using a file-based cache.)

To reduce storage overhead and speed up expiration time-checks, the file modification time will be set in the future. (The file creation timestamp will reflect the time the file was actually created.)

Usage
-----

[](#usage)

Please refer to the [PSR-16 spec](https://packagist.org/packages/psr/simple-cache) for the API description.

### Security

[](#security)

In a production setting, consider specifying appropriate `$dir_mode` and `$file_mode` constructor-arguments for your hosting environment - the defaults are a typical choice, but you may be able to tighten permissions on your system, if needed.

### Garbage Collection

[](#garbage-collection)

Because this is a file-based cache, you do need to think about garbage-collection as it relates to your use-case.

This cache-implementation does not do any automatic garbage-collection on-the-fly, because this would periodically block a user-request, and garbage-collection across a file-system isn't very fast.

A public method `cleanExpired()` will flush expired entries - depending on your use-case, consider these options:

1. For cache-entries with non-dynamic keys (e.g. based on primary keys, URLs, etc. of user-managed data) you likely don't need garbage-collection. Manually clearing the folder once a year or so might suffice.
2. For cache-entries with dynamic keys (such as Session IDs, or other random or pseudo-random keys) you should set up a cron-job to call the `cleanExpired()` method periodically, say, once per day.

For cache-entries with dynamic keys in the millions, as mentioned, you probably don't want a file-based cache.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 55.6% 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 ~423 days

Recently: every ~723 days

Total

8

Last Release

540d ago

Major Versions

0.1.1 → 1.0.02017-02-07

1.2.0 → 2.0.02022-08-24

PHP version history (2 changes)0.1.0PHP &gt;= 5.6

1.2.0PHP &gt;= 8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5709900?v=4)[Thomas Nordahl Pedersen](/maintainers/thomasnordahl-dk)[@thomasnordahl-dk](https://github.com/thomasnordahl-dk)

![](https://avatars.githubusercontent.com/u/13201214?v=4)[Bo Andersen](/maintainers/boan-jfm)[@boan-jfm](https://github.com/boan-jfm)

![](https://avatars.githubusercontent.com/u/32329468?v=4)[Jesper Østergaard Jensen](/maintainers/JyskFynskeMedierJoej)[@JyskFynskeMedierJoej](https://github.com/JyskFynskeMedierJoej)

![](https://avatars.githubusercontent.com/u/25659854?v=4)[Michelle Fich](/maintainers/mifich)[@mifich](https://github.com/mifich)

---

Top Contributors

[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (10 commits)")[![boan-jfm](https://avatars.githubusercontent.com/u/13201214?v=4)](https://github.com/boan-jfm "boan-jfm (3 commits)")[![vortrixs](https://avatars.githubusercontent.com/u/15426116?v=4)](https://github.com/vortrixs "vortrixs (3 commits)")[![thomasnordahl-dk](https://avatars.githubusercontent.com/u/5709900?v=4)](https://github.com/thomasnordahl-dk "thomasnordahl-dk (1 commits)")[![visiover](https://avatars.githubusercontent.com/u/4103975?v=4)](https://github.com/visiover "visiover (1 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[illuminate/contracts

The Illuminate Contracts package.

706130.3M13.3k](/packages/illuminate-contracts)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

378604.0k104](/packages/flow-php-etl)

PHPackages © 2026

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