PHPackages                             alexkratky/cachex - 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. alexkratky/cachex

ActiveLibrary[Caching](/categories/caching)

alexkratky/cachex
=================

Class to work with cache.

v1.0.0(6y ago)0533MITPHPPHP &gt;=7.0

Since Sep 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/AlexKratky/CacheX)[ Packagist](https://packagist.org/packages/alexkratky/cachex)[ Docs](https://panx.eu/)[ RSS](/packages/alexkratky-cachex/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (5)Used By (3)

Cache
=====

[](#cache)

Class to work with cache.

### Installation

[](#installation)

`composer require alexkratky/cachex`

### Usage

[](#usage)

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

use AlexKratky\Cache;
use AlexKratky\Logger;

Cache::setDirectory(__DIR__ . '/cache/');
Logger::setDirectory(__DIR__ . '/cache/');

Cache::save("test.json", array(
    "name" => "Alex"
));
```

### Working with Cache

[](#working-with-cache)

Working with Cache in panx framework is quite easy. If you need to save some variable to cache, you can do it by calling `Cache::save($name, $data) `, where `$name` is the name of the variable and `$data` is its value.

After you saved data, you can retrieve them by calling `Cache::get($name, $cacheTime)`, where `$name` is the name of the variable and `$cacheTime` is time in seconds. If the stored data in cache is older then this limit, it will return `false`. Second parameter is optional. If you do not pass any value as second parameter, Cache class will use the default value (10 seconds).

`Cache::get()` will return the data or `false` if the variable is not stored in cache or it is too old.

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

use AlexKratky\Cache;
use AlexKratky\Logger;

Cache::setDirectory(__DIR__ . '/cache/');
Logger::setDirectory(__DIR__ . '/cache/');

$c = Cache::get("user", 30);
if($c !== false) {
    var_dump($c);
}
$c_arr = array(
    "ID" => 1,
    "name" => "Alex",
    "email" => "example@example.com",
    "age" => 19,
    "admin" => true
);
Cache::save("user", $c_arr);
```

- `Cache::destroy(string $name): bool` - Deletes specified cache file.
- `Cache::clearUnused($dir = null, $time = 86400)` - Deletes unused cache files (Older then $time). The $dir parameter must be specified only from terminal (\_*DIR*\_).
- `Cache::clearAll($dir = null)` - Deletes whole cache directory. The $dir parameter must be specified only from terminal (\_*DIR*\_).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

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

Total

3

Last Release

2192d ago

Major Versions

v0.2.0 → v1.0.02020-05-12

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpdatacachecachingcachex

### Embed Badge

![Health badge](/badges/alexkratky-cachex/health.svg)

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

###  Alternatives

[voku/simple-cache

Simple Cache library

322.5M7](/packages/voku-simple-cache)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2984.6k1](/packages/alekseykorzun-memcached-wrapper-php)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15191.3k7](/packages/rapidwebltd-rw-file-cache)

PHPackages © 2026

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