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 3y 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 3d ago

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 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

2796d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85dfb16c489e5cd4d8514f3a5454154d10cb0cddac3ce4a6ef73562eb7ad6d61?d=identicon)[X-NicON](/maintainers/X-NicON)

---

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

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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