Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Cache Laravel Package

laminas/laminas-cache

Laminas Cache provides flexible caching for PHP applications, with adapters for common backends, cache storage, patterns, plugins, and PSR-compatible integrations. Includes tools for configuring, managing, and testing cache behavior in Laminas apps.

View on GitHub
Deep Wiki
Context7

CallbackCache

The callback cache pattern caches the results of arbitrary PHP callables.

Quick Start

use Laminas\Cache\Pattern\CallbackCache;
use Laminas\Cache\Pattern\PatternOptions;

// Or the equivalent manual instantiation:
$callbackCache = new CallbackCache(
    $storage,
    new PatternOptions([
        'cache_output' => true,
    ])
);

Storage Adapter

The $storage adapter can be any adapter which implements the StorageInterface. Check out the Pattern Quick Start-Section for a standard adapter which can be used here.

Configuration Options

Option Data Type Default Value Description
storage string|array|Laminas\Cache\Storage\StorageInterface none deprecated Adapter used for reading and writing cached data.
cache_output bool true Whether or not to cache callback output.

Examples

Instantiating the Callback Cache Pattern

use Laminas\Cache\Pattern\CallbackCache;

$callbackCache = new CallbackCache($storage);

Available Methods

In addition to the methods defined in the PatternInterface and the StorageCapableInterface, this implementation provides the following methods.

namespace Laminas\Cache\Pattern;

use Laminas\Cache\Exception;

class CallbackCache extends AbstractStorageCapablePattern
{
    /**
     * Call the specified callback or get the result from cache
     *
     * [@param](https://github.com/param)  callable   $callback  A valid callback
     * [@param](https://github.com/param)  array      $args      Callback arguments
     * [@return](https://github.com/return) mixed Result
     * [@throws](https://github.com/throws) Exception\RuntimeException if invalid cached data
     * [@throws](https://github.com/throws) \Exception
     */
    public function call(callable $callback, array $args = []): mixed;

    /**
     * Intercept method overloading; proxies to call()
     *
     * [@param](https://github.com/param)  callable-string $function  Function name to call
     * [@param](https://github.com/param)  array  $args      Function arguments
     * [@return](https://github.com/return) mixed
     * [@throws](https://github.com/throws) Exception\RuntimeException
     * [@throws](https://github.com/throws) \Exception
     */
    public function __call(string $function, array $args): mixed;

    /**
     * Generate a unique key in base of a key representing the callback part
     * and a key representing the arguments part.
     *
     * [@param](https://github.com/param)  callable   $callback  A valid callback
     * [@param](https://github.com/param)  array      $args      Callback arguments
     * [@return](https://github.com/return) non-empty-string
     * [@throws](https://github.com/throws) Exception\RuntimeException
     * [@throws](https://github.com/throws) Exception\InvalidArgumentException
     */
    public function generateKey(callable $callback, array $args = []): string;
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport