Download the PHP package pulkitjalan/multicache without Composer
On this page you can find all versions of the php package pulkitjalan/multicache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pulkitjalan/multicache
More information about pulkitjalan/multicache
Files in pulkitjalan/multicache
Package multicache
Short Description Adds array caching to Laravels cache drivers and custom drivers
License MIT
Homepage https://github.com/pulkitjalan/multicache
Informations about the package multicache
Multicache
Adds array caching to Laravels cache drivers and custom drivers.
Requirements
- PHP >= 5.5.9
- Laravel = 5.1
Laravel 5.2 natively supports a caching multiple items.
Installation
Install via composer - edit your composer.json
to require the package.
Then run composer update
in your terminal to pull it in.
Now add the following to the providers
array in your config/app.php
Usage
Any existing cache drivers and custom drivers will have access to the following new methods:
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
Below are a few examples of how to use the functions and what they return.
Has
Get
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:
Forget
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...