PHPackages                             pulkitjalan/multicache - 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. pulkitjalan/multicache

AbandonedArchivedLibrary[Caching](/categories/caching)

pulkitjalan/multicache
======================

Adds array caching to Laravels cache drivers and custom drivers

0.3.1(10y ago)719.0k↓50%4[1 PRs](https://github.com/pulkitjalan/multicache/pulls)1MITPHPPHP &gt;=5.5.9

Since Sep 19Pushed 7y ago2 watchersCompare

[ Source](https://github.com/pulkitjalan/multicache)[ Packagist](https://packagist.org/packages/pulkitjalan/multicache)[ Docs](https://github.com/pulkitjalan/multicache)[ RSS](/packages/pulkitjalan-multicache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (1)

Multicache
==========

[](#multicache)

> Adds array caching to Laravels cache drivers and custom drivers.

[![Build Status](https://camo.githubusercontent.com/5a57e42b3da83dcc9a15a0d07cb5bca93fb1bf12de06877bd7499cf2dd3a0f94/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f70756c6b69746a616c616e2f6d756c746963616368652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/pulkitjalan/multicache)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d6d136e53d5ca8e36e862fc79ed71cc0b85be19f3aaa97eed029f953a99424c7/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70756c6b69746a616c616e2f6d756c746963616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/pulkitjalan/multicache/)[![Coverage Status](https://camo.githubusercontent.com/e585bdf7767bee3ee3b594e5f4f0b1388f9a169409ee20809ca50c26d577bf09/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f70756c6b69746a616c616e2f6d756c746963616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/pulkitjalan/multicache/code-structure/master)[![License](https://camo.githubusercontent.com/30597ff9a350144f03bffdd9183e16468e0b3ca1193e1d08591d992622738d55/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://www.opensource.org/licenses/MIT)[![Latest Version](https://camo.githubusercontent.com/b0eac53a6b0883f7d6f4a35dc6a2c1d4fb10701f95755a0dd077b1cc0de1d7b3/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70756c6b69746a616c616e2f6d756c746963616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pulkitjalan/multicache)[![Total Downloads](https://camo.githubusercontent.com/c755a5fbe966c6dd8b2d58d82c525b4cf57ef62202f75ef7a7bc08b2280f2c17/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70756c6b69746a616c616e2f6d756c746963616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pulkitjalan/multicache)

Requirements
------------

[](#requirements)

- PHP &gt;= 5.5.9
- Laravel = 5.1

Laravel 5.2 natively supports a caching multiple items.

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

[](#installation)

Install via [composer](https://getcomposer.org/) - edit your `composer.json` to require the package.

```
"require": {
    "pulkitjalan/multicache": "0.3.*"
}
```

Then run `composer update` in your terminal to pull it in.

Now add the following to the `providers` array in your `config/app.php`

```
PulkitJalan\Cache\Providers\MultiCacheServiceProvider::class
```

Usage
-----

[](#usage)

Any existing cache drivers and custom drivers will have access to the following new methods:

```
    /**
     * Determine if an array of items exists in the cache.
     *
     * @param  array  $keys
     * @return array
     */
    public function hasMany(array $keys);

    /**
     * Retrieve an array of items from the cache by keys.
     *
     * @param  array  $keys
     * @param  mixed  $default
     * @return array
     */
    public function getMany(array $keys, $default = null);

    /**
     * Retrieve an array of items from the cache and delete them.
     *
     * @param  array  $keys
     * @param  mixed  $default
     * @return array
     */
    public function pullMany(array $keys, $default = null);

    /**
     * Store an array of items in the cache.
     *
     * @param  array  $items
     * @param  \DateTime|int  $minutes
     * @return void
     */
    public function putMany(array $items, $minutes);

    /**
     * Store an array of items in the cache if the key does not exist.
     *
     * @param  array  $items
     * @param  \DateTime|int  $minutes
     * @return bool
     */
    public function addMany(array $items, $minutes);

    /**
     * Store an array of items in the cache indefinitely.
     *
     * @param  array  $items
     * @return void
     */
    public function foreverMany(array $items);

    /**
     * Get an array of items from the cache, or store the default value.
     *
     * @param  array  $keys
     * @param  \DateTime|int  $minutes
     * @param  \Closure  $callback
     * @return mixed
     */
    public function rememberMany(array $keys, $minutes, Closure $callback);

    /**
     * Get an array of items from the cache, or store the default value forever.
     *
     * @param  array  $keys
     * @param  \Closure  $callback
     * @return mixed
     */
    public function searMany(array $keys, Closure $callback);

    /**
     * Get an array of items from the cache, or store the default value forever.
     *
     * @param  array  $keys
     * @param  \Closure  $callback
     * @return mixed
     */
    public function rememberManyForever(array $keys, Closure $callback);

    /**
     * Remove an array of items from the cache.
     *
     * @param  array  $keys
     * @return bool
     */
    public function forgetMany(array $keys);
```

Most of the existing methods like `has`, `get`, `put`, `forget`... will also accept an array and automatically run the relevant `Many` function. As Expected the original methods will return results in the same format as they always have if called without an array.

Examples
--------

[](#examples)

Below are a few examples of how to use the functions and what they return.

### Has

[](#has)

```
$keys = [
    'one', // exists
    'two', // does not exist
    'three', // exists
];

Cache::hasMany($keys);

// or

Cache::has($keys);

// will return: ['one' => true, 'two' => false, 'three' => true]
```

### Get

[](#get)

```
$keys = [
    'one', // exists
    'two', // does not exist
    'three', // exists
];

Cache::getMany($keys);

// or

Cache::get($keys);

// will return: ['one' => 'data', 'two' => null, 'three' => 'data']
```

### Put

[](#put)

The `put` method works a little differently to `putMany`. Where `putMany` accepts a key value array as the first parameter and the number of minutes to store for as the second parameter, the `put` method takes two separate arrays as the first two parameters and minutes as the third parameter.

Eg:

```
$data = [
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3',
];

Cache::putMany($data, 10);

// or

Cache::put(array_keys($data), array_values($data), 10);
```

### Forget

[](#forget)

```
$keys = [
    'one',
    'two',
    'three',
];

Cache::forgetMany($keys);

// or

Cache::forget($keys);

// will return: ['one' => true, 'two' => true, 'three' => true]
```

How does it work?
-----------------

[](#how-does-it-work)

For any driver that does not have an underlying `Many` method, the methods will call the `Non-Many` version of the method for every item in the array.

For example, when using the `apc` driver, which does not offer its own `getMany` method, then the `get` method will be called ten times if there are ten items in the input array.

Now, when using the `memcached` driver, which does have its own `getMany` method, then the `getMany` method will be called once and the data returned.

Currently the `MemcachedStore`, `DatabaseStore`, `RedisStore` and the `ArrayStore` are the only ones to offer their own `Many` methods. **More to come soon...**

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

3892d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4124930?v=4)[Pulkit Jalan](/maintainers/pulkitjalan)[@pulkitjalan](https://github.com/pulkitjalan)

---

Top Contributors

[![pulkitjalan](https://avatars.githubusercontent.com/u/4124930?v=4)](https://github.com/pulkitjalan "pulkitjalan (30 commits)")

---

Tags

laravelarraycache

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pulkitjalan-multicache/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[omaralalwi/lexi-translate

Laravel translation package with morph relationships and caching.

754.3k2](/packages/omaralalwi-lexi-translate)[michele-angioni/support

Support is a Laravel package which promotes the use of best practices and design patterns.

181.4k1](/packages/michele-angioni-support)[makbulut/laravel-aerospike

Aerospike cache driver for Laravel

102.2k](/packages/makbulut-laravel-aerospike)

PHPackages © 2026

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