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

ActiveLibrary[Caching](/categories/caching)

slick/cache
===========

Cache component for Slick Framework

v1.2.1(10y ago)02.3kMITPHP

Since Feb 29Pushed 8y ago1 watchersCompare

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

READMEChangelogDependencies (5)Versions (5)Used By (0)

Slick Cache package
===================

[](#slick-cache-package)

[![Latest Version](https://camo.githubusercontent.com/456be8a7a88ab9cfb3d1a6455b9d6be8134861c52a228a4c776e2085fa7cd8e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f736c69636b6672616d65776f726b2f63616368652e7376673f7374796c653d666c61742d737175617265)](https://github.com/slickframework/cache/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/990a57f1cb62164a0f687e1f3cd7170c53e820a44145db0c81fd605ca1414773/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736c69636b6672616d65776f726b2f63616368652f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/slickframework/cache)[![Coverage Status](https://camo.githubusercontent.com/2bbf6c4edc1a3b95c786b62dbe1dcf9fc3948d82d267e9494179df6ebc769680/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f736c69636b6672616d65776f726b2f63616368652f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slickframework/cache/code-structure?branch=develop)[![Quality Score](https://camo.githubusercontent.com/c120f34af0e054d09d4bc5771d314a073f024eb67d9be419f692fcbb20970bee/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736c69636b6672616d65776f726b2f63616368652f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slickframework/cache?branch=develop)[![Total Downloads](https://camo.githubusercontent.com/e59de69dceb8e7391045cdbe64e82253bb2865c31af549b0af0dd22a4801839a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c69636b2f63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slick/cache)

Slick cache package works with cache providing services installed on your system.

It comes with support for *Memcached* (`memcached` daemon) and *File*(caching data into files) out of the box, but it also defines a driver interface that allows you to add your own drivers to your project.

Install
-------

[](#install)

Via Composer

```
$ composer require slick/cache
```

Usage
-----

[](#usage)

To use a cache driver you simple need to call the `Cache::get()` static method to get an initialized cache driver. Check the following example:

```
use Slick\Cache\Cache;

$cache = Cache::get();
$data = $cache->get('data', false);

if (!$data) {
    $data = file_get_contents("http://www.example.com/api/call.json");
    $cache->set('data', $data);
}
```

In this example we are using the default cache driver with default options, to store some expensive API call data.

> **note**
>
> The default driver is Memcached with the following default options:
>
> - `duration => 120`
> - `host => ‘127.0.0.1’`
> - `port => 11211`

### Changing cache expire time

[](#changing-cache-expire-time)

The expire amount of time is always set when you set a value on the cache driver. As mention above, the default is set to 120 seconds. Using the above example, we will set the time expire amount to 3 minutes for the data from our fictitious API call:

```
use Slick\Cache\Cache;

$cache = Cache::get();
$data = $cache->get('data', false);
if (!$data) {
    $data = file_get_contents("http://www.example.com/api/call.json");
    // Set expire to 3 minutes
    $cache->set('data', $data, 3*60);
}
```

It is also possible to define a global expire amount of time for all `Cache::set()` like this:

```
use Slick\Cache\Cache;

$cache = Cache::get();
// Set global cache expire to 10 minutes
$cache->duration = 10*60;

$data = $cache->get('data', false);
if (!$data) {
    $data = file_get_contents("http://www.example.com/api/call.json");
    // This will use the 10 minutes setting from above
    $cache->set('data', $data);
}
```

### Slick\\Cache\\DriverInterface::set()

[](#slickcachedriverinterfaceset)

Set/stores a value with a given key. If no value is set in the expire parameter the default `Cache::duration` will be used.

```
public DriverInterface DriverInterface::set(string $key, mixed $value [, int $expire = -1])
```

ParametersTypeDescription$keystringThe key where value will be stored$valuemixedThe value to store$expireintThe live time of cache in secondsReturnDescriptionSlick\\Cache\\DriverInterfaceA `DriverInterface` instance for chaining method calls.### Slick\\Cache\\DriverInterface::get()

[](#slickcachedriverinterfaceget)

Retrieves a previously stored value. You can optionally set the value returned in case of cache driver has no value for provided key.

```
public mixed DriverInterface::get(string $key [, mixed $default = false])
```

ParametersTypeDescription$keystringThe key where value was stored$defaultmixedThe value returned if cache driver has no value for provided keyReturnDescriptionmixedThe stored value or the default value if cache driver has no value for provided key### Slick\\Cache\\DriverInterface::erase()

[](#slickcachedriverinterfaceerase)

Erase the value stored with a given key. You can use the “?” and “*" wildcards to delete all matching keys. The "?" means a place holders for one unknown character, the "*” is a place holder for various

```
public DriverInterface DriverInterface::erase(string $key)
```

ParametersTypeDescription$keystringThe key where value was storedReturnDescriptionSlick\\Cache\\DriverInterfaceA `DriverInterface` instance for chaining method calls.> **warning**
>
> The use of “?” and “\*” placeholder is only implemented in the drivers that are provided by Slick cache component. If you create your own cache driver you need to handle the placeholders key search implementation.

> **tip**
>
> If you are implementing your own cache driver and want to have the “?” and “\*” placeholders search you can extend `Slick\Cache\Driver\AbstractDriver` witch uses the `DriverInterface::get()` and `DriverInterface::set()` methods to achieve the wildcards key search feature.

Testing
-------

[](#testing)

```
$ vendor/bin/phpunit
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Slick framework](https://github.com/slickframework)
- [All Contributors](https://github.com/slickframework/database/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Total

2

Last Release

3693d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

cachememcachedslick

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tedivm/stash

The place to keep your cache.

9824.8M124](/packages/tedivm-stash)[tedivm/stash-bundle

Incorporates the Stash caching library into Symfony.

841.4M16](/packages/tedivm-stash-bundle)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[cache/memcached-adapter

A PSR-6 cache implementation using Memcached. This implementation supports tags

161.9M14](/packages/cache-memcached-adapter)[aplus/cache

Aplus Framework Cache Library

161.6M4](/packages/aplus-cache)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4441.1k1](/packages/robinn-phpcacheadmin)

PHPackages © 2026

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