Weave 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
Array Adapter

Array Adapter Laravel Package

cache/array-adapter

In-memory PSR-6 and PSR-16 cache pool for tests and short-lived scripts, with tags, hierarchical keys, and an optional item limit. Values last only for the current PHP process.

View on GitHub
Deep Wiki
Context7

cache/array-adapter provides an in-memory PSR-6 cache pool and PSR-16 implementation for PHP. Values live only for the current process, making the adapter ideal for tests, short-lived scripts, and local development where a persistent backend is unnecessary.

The pool supports tags and hierarchical keys, and accepts an optional positive maximum item count. When the limit is reached, saving a new key evicts the item in the next storage slot; updating an existing key keeps its slot.

  • In-memory PSR-6 pool and PSR-16 cache
  • Tag support and hierarchical keys
  • Optional item limit with slot-based eviction
  • Process-local values — no external service
  • Great for tests and short-lived scripts
Frequently asked questions about Array Adapter
What is cache/array-adapter used for?
It provides an in-memory PSR-6 cache pool, with PSR-16 implementations also noted in the README, backed by a plain PHP array. Values live only for the current PHP process, so it is intended for tests and short-lived scripts rather than shared or persistent caching. It also supports tags, hierarchical keys, and an optional maximum item count.
Does cache/array-adapter work with Laravel's Cache facade?
Not directly. Laravel's Cache facade and Repository contract are PSR-16 or Laravel-native Store shapes, while this package primarily implements Psr\Cache\CacheItemPoolInterface (PSR-6). To use it through Laravel's cache API you would need to write a custom Illuminate\Contracts\Cache\Store wrapper. For most Laravel apps, the built-in array store is the simpler equivalent.
How do I install cache/array-adapter in a Laravel project?
Install it as a dev dependency with composer require --dev cache/array-adapter:^3.0. Then bind it in your test case or service provider if your code type-hints Psr\Cache\CacheItemPoolInterface, for example $this->app->instance(CacheItemPoolInterface::class, new ArrayCachePool()). Avoid adding it to production requirements unless you have a genuine PSR-6 consumer.
Is cache/array-adapter a good replacement for Laravel's array cache store?
For typical Laravel applications, no. Laravel's native array store (CACHE_STORE=array) is request-scoped, in-memory, TTL-aware, zero-config, and already integrated with the Cache facade and test helpers. cache/array-adapter only adds value when code is deliberately written against PSR-6 rather than Laravel's cache contracts. In that narrow case it is a cheap test binding.
Can I use cache/array-adapter in production?
It is not suitable as a production cache store. All values are process-local and disappear at the end of the request or job, there is no cross-process sharing, and there is no auto-GC on read. In long-running processes such as Octane, Swoole, or queue workers, the pool can persist and grow across jobs, creating a slow memory leak risk.
How do tags and hierarchical keys work in ArrayCachePool?
The pool supports PSR-6 tags and hierarchical keys, letting you group or namespace cache items in memory. Version 3 stores a generation snapshot with each tagged item and a separate marker for each tag. Because array caches are process-local, new workers start with an empty cache and tags do not persist across processes.
How does the maximum item count constructor argument work?
Pass a positive integer as the first constructor argument, such as new ArrayCachePool(1000), to cap stored items. The default null keeps every item for the process lifetime. When the pool reaches the limit, saving a new key removes the key in the next storage slot, while updating an existing key keeps its slot.
Which Laravel and PHP versions does cache/array-adapter support?
The package is framework-agnostic and does not declare Laravel version support; compatibility is determined by its PHP and PSR cache interface requirements. The README shows installation for ^3.0, but release notes in the split repository are minimal, so check the upstream php-cache/cache monorepo and Packagist metadata for exact PHP constraints. Because the split repo has low activity, test against your target PHP version in CI before adopting.
Is cache/array-adapter maintained and safe to depend on?
The GitHub repository is a read-only subtree split of the php-cache/cache monorepo, so fixes land upstream and the visible repo has no independent release velocity. Adoption is low, and release notes are thin, making upgrade impact hard to assess. Treat it as a narrow dev-only utility and verify PHP compatibility in CI rather than relying on a stated support window.
How should I test code that depends on a PSR-6 cache pool?
Install cache/array-adapter with --dev and bind ArrayCachePool to Psr\Cache\CacheItemPoolInterface in your test container. That gives you a fast, in-memory PSR-6 implementation without external services. For Laravel-native cache code, prefer the built-in array store and Cache::spy() or Cache::fake() test ergonomics instead.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo