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 apps with storage adapters (memory, filesystem, Redis, etc.), plugins, and cache patterns. Includes PSR-6/PSR-16 support, configuration options, and utilities for improving performance and reducing expensive operations.

View on GitHub
Deep Wiki
Context7

Storage Capabilities

Storage capabilities describe how a storage adapter works, and which features it supports.

To get capabilities of a storage adapter, you can use the method getCapabilities(), but only the storage adapter and its plugins have permissions to change them.

Because capabilities are mutable, you can subscribe to the "change" event to get notifications; see the examples for details.

If you are writing your own plugin or adapter, you can also change capabilities because you have access to the marker object and can create your own marker to instantiate a new instance of Laminas\Cache\Storage\Capabilities.

Available Methods

namespace Laminas\Cache\Storage;

use ArrayObject;
use stdClass;
use Laminas\Cache\Exception;
use Laminas\EventManager\EventsCapableInterface;

final class Capabilities
{
    /**
     * [@param](https://github.com/param) int<-1,max> $maxKeyLength
     * [@param](https://github.com/param) SupportedDataTypesArrayShape $supportedDataTypes
     */
    public function __construct(
        /**
         * Maximum supported key length for the cache backend
         */
        public readonly int $maxKeyLength,
        /**
         * Whether the cache backend supports TTL
         */
        public readonly bool $ttlSupported,
        public readonly bool $namespaceIsPrefix,
        /**
         * Contains the supported data types.
         * Depending on the cache backend in use, the type remains as is, is converted to a different type or is not
         * supported at all.
         */
        public readonly array $supportedDataTypes,
        public readonly int|float $ttlPrecision,
        public readonly bool $usesRequestTime,
    ) {
    }
}

Examples

Get Storage Capabilities and do specific Stuff based on them

use Laminas\Cache\Service\StorageAdapterFactoryInterface;
use Psr\Container\ContainerInterface;

/** [@var](https://github.com/var) ContainerInterface $container */
$container = null; // can be any configured PSR-11 container

/** [@var](https://github.com/var) StorageAdapterFactoryInterface $storageFactory */
$storageFactory = $container->get(StorageAdapterFactoryInterface::class);

$cache = $storageFactory->create('filesystem');
$supportedDataTypes = $cache->getCapabilities()->supportedDataTypes;

// now you can run specific stuff in base of supported feature
if ($supportedDataTypes['object']) {
    $cache->set($key, $object);
} else {
    $cache->set($key, serialize($object));
}
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony