PHPackages                             visol/cacheable - 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. visol/cacheable

ActiveNeos-package[Caching](/categories/caching)

visol/cacheable
===============

Allows caching the return value of Flow Framework methods through annotations

0.3.0(3y ago)53.8k↓28%2MITPHP

Since Nov 16Pushed 3y ago3 watchersCompare

[ Source](https://github.com/visol/Visol.Cacheable)[ Packagist](https://packagist.org/packages/visol/cacheable)[ RSS](/packages/visol-cacheable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

Cacheable
=========

[](#cacheable)

This Flow Framework package allows caching the return value of Flow Framework methods through annotations.

Features
--------

[](#features)

- Configure the lifetime
- Configure cache tags
- Optionally protect cache entries with the currently authenticated account or the roles associated to the currently authenticated
- Use a persistent or a transient cache
- This is built on top of the Flow Framework. The caching configuration can be adjusted based on the project's needs.

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

[](#installation)

To get the latest version of Cacheable, require the project using [Composer](https://getcomposer.org):

```
composer require visol/cacheable
```

Usage
-----

[](#usage)

For annotations to work, make sure to import the respective namespaces in your class:

```
use Visol\Cacheable\Annotations as Cacheable;
use Visol\Cacheable\Annotations\Method;
```

You can now add the annotation to methods whose results you want to be cached:

```
/**
 * @return array
 * @Cacheable\Method(lifetime=1800, tags={"rest_service"}, security=Method::SECURITY_ROLES, cacheIdentifier=Method::CACHE_PERSISTENT)
 */
public function executeLongRunningTask(string $someArgument): array
{
    // Fetch data from API or perform long running calculations
}
```

This would cache the return value for 30 minutes in the persistent cache, taking into account all roles of the currently authenticated user, tagged with rest\_service.

Warning: Only use this annotation for static or static like methods. E.g. fetching external data or performing calculations depending solely on supplied parameters.

### Cache lifetime configuration

[](#cache-lifetime-configuration)

You can configure the cache lifetime in seconds:

```
lifetime=1800

```

This will cache your data for 30 minutes.

### Cache tags configuration

[](#cache-tags-configuration)

You can configure an array of cache tags:

```
tags={"tag_1", "tag_2"}

```

This allows you to programmatically flush the cache in your code.

### Security method configuration

[](#security-method-configuration)

The cached data can either be bound to the currently authenticated account or to the roles of the currently authenticated account.

**No protection *(default)*:**

```
security=Method::SECURITY_NONE

```

**Account:**

```
security=Method::SECURITY_ACCOUNT

```

**Roles:**

```
security=Method::SECURITY_ROLES

```

### Cache type

[](#cache-type)

By default, two caches are configured:

**Persistent cache *(default)*:**

```
cacheIdentifier=Method::CACHE_PERSISTENT

```

Stores the data as persistent data in the `FileBackend`.

**Transient cache:**

```
cacheIdentifier=Method::CACHE_TRANSIENT

```

Stores the data in the `TransientMemoryBackend`.

If you need to adjust configuration to your needs, override the caches in your application package's or distribution's `Caches.yaml`. See `Configuration/Caches.yaml` for the default configuration.

### Cache Entry Identifier

[](#cache-entry-identifier)

A cache entry identifier is automatically generated based on namespace, arguments and security settings.

By default the namespace is set to the class and method name.

All supplied arguments are used as is. Be cautious when using complex objects.

Credits
-------

[](#credits)

visol digitale Dienstleistungen GmbH, [www.visol.ch](http://www.visol.ch)

Inspired by:

- Annotation Type Cacheable in Spring Framework
- Python function caching
- [Packagist package yateric/cacheable](https://packagist.org/packages/yateric/cacheable)

License
-------

[](#license)

Cacheable is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~358 days

Total

3

Last Release

1293d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d6e1686bc798a88033f481f209a4f060235147ac7dca4c3391f2d171e30fdd4a?d=identicon)[visol](/maintainers/visol)

---

Top Contributors

[![dhuf](https://avatars.githubusercontent.com/u/1814195?v=4)](https://github.com/dhuf "dhuf (1 commits)")[![lorenzulrich](https://avatars.githubusercontent.com/u/1816023?v=4)](https://github.com/lorenzulrich "lorenzulrich (1 commits)")

### Embed Badge

![Health badge](/badges/visol-cacheable/health.svg)

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

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)

PHPackages © 2026

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