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 1w 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 40% 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

3616d 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

[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)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)

PHPackages © 2026

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