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

ActiveLibrary[Caching](/categories/caching)

lithemod/cache
==============

Caching mechanism using the filesystem.

v1.2.0(1y ago)030MITPHPPHP ^8.0

Since Oct 2Pushed 1y agoCompare

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

READMEChangelogDependencies (1)Versions (10)Used By (0)

Lithe Cache
===========

[](#lithe-cache)

**Lithe Cache** is a simple and efficient caching module that utilizes the filesystem for storage. With it, you can store and retrieve data quickly, improving the performance of your application.

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

[](#installation)

To install the `lithemod/cache` module, use Composer. Run the following command in the root directory of your project:

```
composer require lithemod/cache
```

Usage
-----

[](#usage)

After installation, you can use the `Cache` class to store and retrieve cached data. Follow these steps:

### 1. Configuring the Cache Directory

[](#1-configuring-the-cache-directory)

Before using the cache, define the directory where cached data will be stored. You can do this by calling the `dir` method of the `Cache` class:

```
use Lithe\Support\Cache;

// Define the cache directory
Cache::dir(__DIR__ . '/cache');
```

### 2. Storing Data in the Cache

[](#2-storing-data-in-the-cache)

To store data, use the `add` method. You can specify a key, the data to be stored, the expiration time, and the serializer to use:

```
// Add data to the cache
Cache::add('my_data', ['foo' => 'bar'], 3600, 'serialize'); // Using serialize
```

### 3. Retrieving Data from the Cache

[](#3-retrieving-data-from-the-cache)

To retrieve stored data, use the `get` method:

```
// Retrieve data from the cache
$data = Cache::get('my_data');

if ($data === null) {
    echo "Data not found or expired.";
} else {
    print_r($data);
}
```

### 4. Checking for Data Existence in Cache

[](#4-checking-for-data-existence-in-cache)

To check if a cache entry exists and is valid, you can use the `has` method, which now accepts both a single key and an array of keys:

```
// Check if a single key exists
if (Cache::has('my_data')) {
    echo "Data is in cache.";
}

// Check multiple keys
if (Cache::has(['key1', 'key2'])) {
    echo "All keys are in cache.";
} else {
    echo "One or more keys were not found or are expired.";
}
```

### 5. Invalidating Cache Data

[](#5-invalidating-cache-data)

If you need to remove data from the cache, use the `invalidate` method. You can now invalidate a single key or an array of keys:

```
// Invalidate a single cache key
Cache::invalidate('my_data');

// Invalidate multiple keys
Cache::invalidate(['key1', 'key2', 'key3']);
```

### 6. Using `remember`

[](#6-using-remember)

The `remember` method allows you to retrieve data from the cache or execute a callback to fetch fresh data if not found in the cache:

```
$data = Cache::remember('my_key', function () {
    // Logic to fetch data if not in cache
    return ['foo' => 'bar'];
}, 3600, 'serialize'); // Using serialize

print_r($data);
```

Available Methods
-----------------

[](#available-methods)

- **`Cache::dir($dir)`**: Sets the cache directory.
- **`Cache::add($key, $data, $expiration, $serializer)`**: Stores data in the cache.
- **`Cache::get($key)`**: Retrieves data from the cache.
- **`Cache::has($key)`**: Checks if a single or multiple cache entries exist.
- **`Cache::invalidate($key)`**: Removes specific data from the cache.
- **`Cache::invalidate(array $keys)`**: Removes multiple cache keys.
- **`Cache::clear()`**: Clears all cached data.
- **`Cache::remember($key, $callback, $expiration, $serializer)`**: Retrieves data from the cache or executes a callback to fetch and store new data.

Final Considerations
--------------------

[](#final-considerations)

- **Permissions**: Ensure that the cache directory has appropriate write permissions to avoid access issues.
- **Serialization Methods**: `Lithe Cache` supports both `serialize` and `json` for serializing data before storing it. Choose the method that fits your application's needs.
- **Directory Structure**: `Lithe Cache` organizes cache files into subdirectories to facilitate searching and improve performance in large directories.

With `Lithe Cache`, you have a lightweight and easy-to-use solution for caching that can be integrated into various PHP applications, providing improved performance and a smoother user experience.

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

9

Last Release

650d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56173de3a7bf7099dd8168efd730d3c2fb5df5174a123fdc37cee8c3589e2345?d=identicon)[williamhumbwavali](/maintainers/williamhumbwavali)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/lithemod-cache/health.svg)](https://phpackages.com/packages/lithemod-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)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[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.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

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