PHPackages                             xnicon/simple-php-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. xnicon/simple-php-cache

ActiveLibrary[Caching](/categories/caching)

xnicon/simple-php-cache
=======================

Simple PHP cache

0.2(7y ago)26MITPHPPHP &gt;=5.6

Since Jul 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/XNicON/simple-php-cache)[ Packagist](https://packagist.org/packages/xnicon/simple-php-cache)[ RSS](/packages/xnicon-simple-php-cache/feed)WikiDiscussions master Synced today

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

Simple PHP Cache
================

[](#simple-php-cache)

Quick Start
-----------

[](#quick-start)

To install Simple PHP Cache, simply:

```
$ composer require xnicon/php-simple-cache

```

Code Examples
-------------

[](#code-examples)

### Example One

[](#example-one)

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

use \phpCache\Cache;

$c = new Cache();

if(!$c->has("example")) {
  $c->set("example", 'cache data', 300); // cache result for 5 minutes (300 seconds)
} else {
  echo $c->get("example");
}
```

### Example Two

[](#example-two)

```
$example = $c->get("example");

if($example !== false) {
  echo "Cached: " . $example;
  $c->remove("example"); // remove from cache
} else {
  echo "Cache not found or expired";
}
```

### Example Three

[](#example-three)

```
$c->set("progress", 50, 300); // cache result for 5 minutes (300 seconds)

$progress = $c->get("progress", 0); // default return 0

echo "Progress: " . $progress;
```

Functions
---------

[](#functions)

### \_\_construct($name, $dir, $ext)

[](#__constructname-dir-ext)

Class constructor

- `$name` - name of the cache (default `phpcache`)
- `$dir` - directory where the cache will be stored (default TEMP directory)
- `$ext` - extension of the cache file (default `.cache`)

### set($key, $value, $ttl = 0)

[](#setkey-value-ttl--0)

Writes data to cache

- `$key` - key of the value
- `$value` - value
- `$ttl` - *Time To Live* (in how many seconds value will expire)

### get($key, $default = false)

[](#getkey-default--false)

Reads data from cache

- `$key` - key of the value
- `$default` - is default value return if value by `$key` not found (default `false`)
- return:
    - bool(false) - value not cached or expired
    - array - if success

### remove($key)

[](#removekey)

Removes data from cache

- `$key` - key of the value
- return:
    - bool(false) - key not found
    - bool(true) - success

### has($key)

[](#haskey)

Check exists and not is expired cache

- `$key` - key of the value
- return:
    - bool(false) - not found
    - bool(true) - is found

### clean()

[](#clean)

clean cache file

- return:
    - bool(false) - fail
    - bool(true) - success

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

2888d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6958903?v=4)[xnicon](/maintainers/xnicon)[@XNicON](https://github.com/XNicON)

---

Top Contributors

[![XNicON](https://avatars.githubusercontent.com/u/6958903?v=4)](https://github.com/XNicON "XNicON (2 commits)")

---

Tags

cachefile-cachephp-cachesimple-cache

### Embed Badge

![Health badge](/badges/xnicon-simple-php-cache/health.svg)

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

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)

PHPackages © 2026

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