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

ActiveLibrary[Caching](/categories/caching)

kminek/cache
============

Simplest cache implementation ever!

v2.0.0(8y ago)1485MITPHP

Since Feb 22Pushed 8y ago1 watchersCompare

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

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

Cache
=====

[](#cache)

This is really simple filesystem cache implementation which should work on broad range of PHP versions. Just plug and play - perfect solution for tiny projects and quick scripts where you do not need full-blown cache solutions.

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

[](#installation)

```
$ composer require kminek/cache

```

API
---

[](#api)

```
/**
 * @param string $key
 * @param mixed  $default
 *
 * @return mixed
 */
function cache_get($key, $default = null);

/**
 * @param string   $key
 * @param mixed    $value
 * @param null|int $ttl
 *
 * @return bool
 */
function cache_set($key, $value, $ttl = null);

/**
 * @param string $key
 *
 * @return bool
 */
function cache_delete($key);

/**
 * @return bool
 */
function cache_clear();
```

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';

$cachedData = cache_get('cachedData');

if (!$cachedData) {
    echo 'Saving cache...' . PHP_EOL;
    cache_set('cachedData', array('lorem', 'ipsum'), 5 * 60); // 5 minutes
} else {
    echo 'Data retrieved from cache!' . PHP_EOL;
    var_dump($cachedData);
}
```

Advanced usage
--------------

[](#advanced-usage)

```
// set your custom configuration options (below are default ones)
Kminek_Cache::configure(array(
    'engine' => Kminek_Cache::ENGINE_SERIALIZE, // or Kminek_Cache::ENGINE_JSON or Kminek_Cache::ENGINE_VAR_EXPORT
    'dir' => sys_get_temp_dir(), // where to store cache files
    'prefix' => 'kminek_cache',
    'separator' => '_',
    'extension' => '.cache',
    'ttl' => 60 * 60, // default ttl in seconds (1 hour)
));

// then use cache as you would normally do
$cachedData = cache_get('cachedData');
...
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

3002d ago

Major Versions

v1.0.0 → v2.0.02018-02-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7c918f54bb848b1ab6ac0f623e0aba72e565865aa15b77b4e7eeba354e38256?d=identicon)[kminek](/maintainers/kminek)

---

Top Contributors

[![kminek](https://avatars.githubusercontent.com/u/373962?v=4)](https://github.com/kminek "kminek (6 commits)")

---

Tags

cachephpcache

### Embed Badge

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

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

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[psr/cache

Common interface for caching libraries

5.2k686.9M1.3k](/packages/psr-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2512.2M6](/packages/beste-in-memory-cache)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33313.0k](/packages/anahkiasen-flatten)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23817.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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