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

ActiveLibrary[Caching](/categories/caching)

mima/cache-proxy
================

Decorator for public methods of any classes for proxy request to cache

v1.1(9y ago)017MITPHPPHP &gt;=5.5

Since May 16Pushed 9y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

PHP Cache Proxy
===============

[](#php-cache-proxy)

[![Build Status](https://camo.githubusercontent.com/ec0b35ad1201a3f8180965e4e401af349f1973bd5aa738649c49979c3d62d31e/68747470733a2f2f7472617669732d63692e6f72672f4d696d61546f6d69732f63616368652d70726f78792e737667)](https://travis-ci.org/MimaTomis/cache-proxy)

About library
-------------

[](#about-library)

Proxying calls to any functions to retrieve data from the cache.

- [Installation](#installation)
- [Using](#using)

### Installation

[](#installation)

Run command:

```
composer require mima/cache-proxy

```

Add dependency on your composer.json:

```
{
    "require": {
        "mima/cache-proxy": "~1.0"
    }
}
```

### Using

[](#using)

- [Update cache and retrieve data](#update-cache-and-retrieve-data)
- [Flush data from cache](#flush-data-from-cache)

#### Update cache and retrieve data

[](#update-cache-and-retrieve-data)

Create new instance of `CacheProxy\Proxy` class:

```
use CacheProxy\Proxy;
use CacheProxy\Adapter\DoctrinCacheAdapter;

$adapter = new DoctrinCacheAdapter($doctrinCacheInstance);
$cacheProxy = new Proxy($adapter);
```

The adapter should implement the interface `CacheProxy\Adapter\CacheAdapterInterface`. It is used to adapt the interface to caching in your framework.

You can use one of several prepared adapters or create your own:

- `CacheProxy\Adapter\DoctrinCacheAdapter` implementation for doctrine cache
- `CacheProxy\Adapter\YiiCacheAdapter` implementation for yii2

Use instance of `CacheProxy\Proxy` class in your code as it is:

```
use MyNamespace\AnyClass;
use CacheProxy\Target\ProxyTarger;

$object = new AnyClass();
$target = new ProxyTarget([$object, 'anyMethod'], ['arg1', 'arg2']);

$data = $cacheProxy->proxyTarget($target);
```

Or you may create decorator for your class and depend him from `CacheProxy\Proxy` class:

```
namespace MyNamespace;

use CacheProxy\Proxy

class AnyDecorator
{
    /**
     * @var AnyClass
     */
    protected $class;
    /**
     * @var Proxy
     */
    protected $proxy;

    public function __construct(AnyClass $class, Proxy $cacheProxy)
    {
        $this->class = $class;
        $this->cacheProxy = $proxy;
    }

    public function anyMethod($arg1, $arg2)
    {
        $target = new ProxyTarget([$this->class, 'anyMethod'], func_get_args());

        return $this->cacheProxy->proxyTarget($target);
    }
}
```

Key for caching data generated on runtime in `CacheProxy\Proxy` class. If you want specify any suffix for cache key, pass second argument to `CacheProxy\Proxy::proxyTarget` method.

```
$cityId = 1;
$cacheProxy->proxyTarget($target, $cityId);
```

To set the *ttl* for storing data in cache, pass third argument to `CacheProxy\Proxy::proxyTarget` method.

```
$ttl = 3600;
$cacheProxy->proxyTarget($target, null, $ttl);
```

#### Flush data from cache

[](#flush-data-from-cache)

If you want remove all cache data, do as shown below:

```
// this code update cache ad return data
$key = md5('any-key');
$cacheProxy->proxyTarget($target, null, $ttl);

// this code flush all data from cache by target and key
$cacheProxy->flushTarget($target, $key);
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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

Total

2

Last Release

3571d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/715813?v=4)[Mima Tomis](/maintainers/MimaTomis)[@MimaTomis](https://github.com/MimaTomis)

---

Top Contributors

[![MimaTomis](https://avatars.githubusercontent.com/u/715813?v=4)](https://github.com/MimaTomis "MimaTomis (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32136.0k](/packages/beryllium-cachebundle)

PHPackages © 2026

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