PHPackages                             rodrigovr/php-aop-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. rodrigovr/php-aop-cache

ActiveLibrary[Caching](/categories/caching)

rodrigovr/php-aop-cache
=======================

Cache method calls using Aspect-Oriented Programming techniques.

00PHP

Since Sep 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/rodrigovr/php-aop-cache)[ Packagist](https://packagist.org/packages/rodrigovr/php-aop-cache)[ RSS](/packages/rodrigovr-php-aop-cache/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-aop-cache
=============

[](#php-aop-cache)

Aspect-Oriented Caching of Method Calls Using Runkit7

Goals
-----

[](#goals)

This project allows you to decorate method calls with a caching behavior. In other words, this means that, without modifing the source code of a foreign class, you can "plug" a cache mechanism to a choosen public method.

When is it useful?
------------------

[](#when-is-it-useful)

1. Before refactoring large code bases.
2. When dealing with third-party code.
3. To avoid licensing issues.
4. To avoid repeated code.
5. To easily test caching backends.

This is not a complete list, just some insights!

Dependencies
------------

[](#dependencies)

- install and enable runkit7
- php 7.2+

What can be cached?
-------------------

[](#what-can-be-cached)

You must decorate only user defined methods. Native classes are not supported.

Ex: You cannot attach directly to PDO::query.

How to use?
-----------

[](#how-to-use)

1. install with composer: `composer require rodrigovr/php-aop-cache`
2. as soon as possible, instantiate the Decorator with a given cache implementation:

```
use rodrigovr\Aop;

...

$decorator = Cache\Decorator::create(new Cache\MemoryCache);
```

3. attach the decorator to any methods you want to cache results:

```
$decorator->attachTo('SomeClass', 'methodName')
          ->attachTo('SomeClass', 'anotherMethodName')
          ->attachTo('AnotherClass', 'oneMoreMethod');
```

4. if needed, set how long (in seconds), results will be cached

```
// cache results up to 5 minutes
$decorator->expires(300);
```

5. you can also limit cache entries by size (in bytes)

```
// results over 10MB will not be saved
$decorator->limit(10000000);
```

6. multiple decorators are supported

```
$applyMemoryCache = Cache\Decorator::create(new Cache\MemoryCache);
$applySessionCache = Cache\Decorator::create(new Cache\SessionCache);
$applyApcuCache = Cache\Decorator::create(new Cache\SessionCache);
```

7. you can create custom caching backends

```
use rodrigovr\Aop;

class MyCache implements Cache\Storage {
    public function save($key, $value, $ttl) {
        // your custom save implementation
    }
    public function load($key) {
        // custom load implementation
    }
}

$decorator = Cache\Decorator::create(new MyCache)->expires(120);
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![rodrigovr](https://avatars.githubusercontent.com/u/4616411?v=4)](https://github.com/rodrigovr "rodrigovr (5 commits)")

### Embed Badge

![Health badge](/badges/rodrigovr-php-aop-cache/health.svg)

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

###  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)
