PHPackages                             clowdy/multi-memcached - 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. clowdy/multi-memcached

ActiveLibrary[Caching](/categories/caching)

clowdy/multi-memcached
======================

Multiple memcached connection handler for Laravel and elasticache support

0.2.2(10y ago)426.8k6MITPHPPHP &gt;=5.4.0

Since Sep 26Pushed 7y ago5 watchersCompare

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

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Multiple Memcached Connections
==============================

[](#multiple-memcached-connections)

Multiple memcached connection handler for Laravel cache and elasticache support. There is also support for `getMulti`, `putMulti`, `foreverMulti` and `forgetMulti` specifically for memcached only.

**The cache driver can not be swapped if you make use of the additional `getMulti`, `putMulti`, `foreverMulti` or `forgetMulti` functions or the `get`, `put`, `forever`, `forget` with arrays. They are specific for memcached only!**

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

[](#installation)

You can install the package using the [Composer](https://getcomposer.org/) package manager:

```
{
    "require": {
        "clowdy/multi-memcached": "0.2.*"
    }
}
```

Update `app/config/app.php` with the new service provider.

```
'providers' => array(
    ...
    //'Illuminate\Cache\CacheServiceProvider',
    'Clowdy\Cache\CacheServiceProvider',
    ...
)
```

Configuration
-------------

[](#configuration)

The package makes use of the existing memcached configs in `app/config/cache.php`, with a slightly modified structure.

Example:

```
...
'memcached' => array(
    'default' => 'data1',

    'connections' => array(

        // cluster
        'data1' => array(
            array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
            array('host' => '127.0.0.1', 'port' => 11212, 'weight' => 100)
        ),

        // single node
        'data2' => array(
            array('host' => '127.0.0.1', 'port' => 11213, 'weight' => 100),
        ),

        // elasticache cluster
        'data3' => array(
            'elasticache' => true
            'servers' => array(
                array('host' => 'memcached.cache.amazonaws.com', 'port' => 11211, 'weight' => 100),
            ),
        )
    )
),
```

Any other providers in Laravel that make use of memcached will use the default connection. For example the `session` provider using the `memcached` driver will use the default connection.

Example Usage
-------------

[](#example-usage)

```
Cache::connection('data1')->get('somekey');

// or you can omit the connection method to use the default connection.

Cache::get('somekey');

// also perform a multi get using an array

Cache::get(['key1', 'key2']);
```

or

```
