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

ActiveProject[Caching](/categories/caching)

kbra/cache
==========

KBRA Cache

0.2.1(7y ago)41.0k2Apache 2.0PHP

Since May 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/KBRATech/Cache)[ Packagist](https://packagist.org/packages/kbra/cache)[ RSS](/packages/kbra-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

KBRA Cache
==========

[](#kbra-cache)

A simple PHP cache library

Getting Started
---------------

[](#getting-started)

### Prerequisites

[](#prerequisites)

- PHP 5.6 or 7
- Some [caching driver](https://github.com/PHPSocialNetwork/phpfastcache#supported-drivers-at-this-day-) supported by phpfastcache

### Installing

[](#installing)

Install with composer:

```
composer require kbra/cache

```

Set the configuration based on your cache driver. Using Redis, your config might look something like this:

```
$settings = [
    'driver' => 'redis',
    'maxRetries' => 3,
    'config' => [
        'defaultTtl' => 900,
        'host' => 'cache.example.com',
        'port' => 6379,
        'database' => 11,
        'password' => 'SuperSecretPassword',
        'timeout' => 3,
    ],
];

$cacheService = new CacheService($settings);

```

*Right now this library only properly handles connection errors from Redis*

You may choose to connect your cache driver manually:

```
$cacheService->connect();

```

But if you don't, a connection will be attempted the first time it is needed.

To save data to the cache:

```
$cacheService->set('some-data', $data);

```

And to retrieve it from the cache:

```
$data = $cacheService->get('some-data');

```

You can pass some extra options when saving data to the cache. A unique cache key will be generated based on the name and options passed. For example, if you wanted to cache a database query with some parameters:

```
$query = "SELECT * FROM table WHERE thing = :thing";
$params = [':thing' => 'something'];
$result = $pdo->fetchAll($query, $params);

$cacheService->set($query, $result, $params);

```

And to get the cached result:

```
$result = $cacheService->get($query, $params);

```

You can also save some tags associated with the cache data, which can be used later to remove items from the cache:

```
$tags = [$userName, 'portfolio'];
$cacheService->set($query, $result, $params, $tags);

// clear ALL caches tagged with 'portfolio'
$cacheService->clearTags('portfolio');

```

Running the tests
-----------------

[](#running-the-tests)

`composer test` or `phpunit`

Built With
----------

[](#built-with)

- [phpfastcache](https://github.com/PHPSocialNetwork/phpfastcache) - A PHP high-performance backend cache system

Contributing
------------

[](#contributing)

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/KBRATech/Cache/releases).

Authors
-------

[](#authors)

- **Erik Hierhager** -

See also the list of [contributors](https://github.com/KBRATech/Cache/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details

Acknowledgments
---------------

[](#acknowledgments)

- Kroll Bond Rating Agency, Inc.
- Rubber ducks

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

2907d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40edb7ef5d404c9042efcdf458b9640b52b9a05ba15e7ab2057170651e701a2a?d=identicon)[ethierhager](/maintainers/ethierhager)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/kbra-cache/health.svg)](https://phpackages.com/packages/kbra-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)[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)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)

PHPackages © 2026

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