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

ActiveLibrary[Caching](/categories/caching)

sugiphp/cache
=============

SugiPHP Cache Component

1.1.0(9y ago)26862MITPHPPHP &gt;=5.3

Since Dec 16Pushed 9y ago2 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (2)

Cache
=====

[](#cache)

[![Build Status](https://camo.githubusercontent.com/05a0bd6750315d8bd8216bca84cd816ce5982c93a4b09367e08e1c1b86ab0a20/68747470733a2f2f7472617669732d63692e6f72672f537567695048502f43616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SugiPHP/Cache)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/cb7655908d2f1f06a4f38b731e258f5fb3825a5a5f2b46c5e56ed3d438d9d74f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f537567695048502f43616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/SugiPHP/Cache/?branch=master)

SugiPHP cache component provides a simple and unified API for several caching systems like APC, Memcached and file based cache.

One of the most important features of the caching systems is invalidating items after a specified period of time. This will give you the ability to cache some time consuming queries like the total number of adverts in your site, and not worry about if some advert is deleted or some adverts are posted, but instead set a time after which that number is invalidated and needs to be refreshed.

One other feature is that no matter if the store is actually running (caching items) or not it will not produce any errors or exceptions. Instead it will return NULL on any get requests. In the above example this means that your code will be fooled to count adverts every time, maybe slowing down performance, but still working. Your code will still work on some development or testing environments where no cache is available nor is needed.

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

[](#installation)

```
composer require sugiphp/cache ~1.0
```

### Settings

[](#settings)

- Using APC (APCu) as a cache:

```

```

- Using file-based cache:

```

```

- Using Memcached:

```

```

- NullStore and ArrayStore

Those two classes are not real cache storages, but they are usefull on development environments and for unit tests. ArrayStore caches values only for a lifetime of the script, and thus the expiration time is not implemented. All store values will be flushed after the script is over.

```

```

NullStore is actually a fake store. It is used to check your code is operational even if there is no cache storages available or if there is a problem with existing ones, e.g. no space left on the server or there is no connection with Memcached. Other use is when you wish your code to work without any caching for a while. Especially usefull on development when any caching mechanism can be a disadvantage.

```

```

Usage
-----

[](#usage)

Caching is done by setting a key-value pairs in a store.

### Store a value in a cache

[](#store-a-value-in-a-cache)

```

```

#### Add a value if it is not already been stored

[](#add-a-value-if-it-is-not-already-been-stored)

```

```

### Retrieve value from the cache

[](#retrieve-value-from-the-cache)

```

```

### Delete a value

[](#delete-a-value)

```

```

### Check value is set

[](#check-value-is-set)

```

```

### Increment / decrement value

[](#increment--decrement-value)

```

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3565d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/991c2430ace2ac70cb06507ae39e9e556e43bff5380e45ddd72c0f0294347794?d=identicon)[tzappa](/maintainers/tzappa)

---

Top Contributors

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

---

Tags

cachememcachedapcmemcache

### Embed Badge

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

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

###  Alternatives

[tedivm/stash

The place to keep your cache.

9824.8M124](/packages/tedivm-stash)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[tedivm/stash-bundle

Incorporates the Stash caching library into Symfony.

841.4M16](/packages/tedivm-stash-bundle)[ihor/cachalot

Cache a lot in a proper way (APC, XCache, Memcached, Redis, Couchbase)

2528.1k](/packages/ihor-cachalot)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4441.1k1](/packages/robinn-phpcacheadmin)[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)

PHPackages © 2026

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