PHPackages                             laurent22/kache - 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. laurent22/kache

ActiveLibrary[Caching](/categories/caching)

laurent22/kache
===============

Simple cache system with support for multiple drivers.

1.0(12y ago)2181MITPHP

Since Feb 16Pushed 12y ago1 watchersCompare

[ Source](https://github.com/laurent22/kache)[ Packagist](https://packagist.org/packages/laurent22/kache)[ RSS](/packages/laurent22-kache/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Kache
=====

[](#kache)

A simple cache system with support for multiple drivers and a focus on performance. There is only a minimal wrapper between the exposed API and the underlying driver so as to keep the library as fast as possible.

Installation
============

[](#installation)

Either checkout the code and require `src/Kache.php`. Or use Composer:

```
"require": { "laurent22/kache": "1.*" }

```

Setup
=====

[](#setup)

Using the file driver:
----------------------

[](#using-the-file-driver)

```
Kache::setup(array(
	'driver' => 'file',
	'path' => '/path/to/cache_folder',
));
```

Using the Redis driver:
-----------------------

[](#using-the-redis-driver)

```
Kache::setup(array(
	'driver' => 'redis',
	'server' => array(
		'host' => '127.0.0.1',
		'port' => 6379,
		'dbindex' => 1,
	),
));
```

Using the null driver (to disable caching):
-------------------------------------------

[](#using-the-null-driver-to-disable-caching)

```
Kache::setup(array(
	'driver' => 'null',
));
```

Usage
=====

[](#usage)

The class instance can be accessed either via `Konfig::instance()` or by the convenience method `k()`. For example:

```
k()->set('somekey', 'somevalue', 120); // Cache for 2 minutes
var_dump(k()->get('somekey'));
$k()->delete('somekey');
```

You may also use the `getOrRun()` method which will either return the given key or, if it doesn't exist, will do the following:

- run the provided function.
- set the key to the value returned by the function. This allows simplifying the boiler plate code needed when getting/setting cache values. For example, the following code:

```
function getName() {
	$name = k()->get('name');
	if ($name !== null) return $name;
	$name = getNameFromDb();
	k()->set('name', $name, 600);
	return $name;
}
```

can be simplified to just this:

```
function getName() {
	return k()->getOrRun('name', function() {
		return getNameFromDb();
	}, 600);
}
```

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Unknown

Total

1

Last Release

4563d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24895592?v=4)[lau22](/maintainers/lau22)[@Lau22](https://github.com/Lau22)

### Embed Badge

![Health badge](/badges/laurent22-kache/health.svg)

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

###  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)
