Skip to content

Instantly share code, notes, and snippets.

@teameh
Created May 13, 2016 11:11
Show Gist options
  • Save teameh/b1c39c27f55264f2bf5fd4ca05b23ad8 to your computer and use it in GitHub Desktop.
Save teameh/b1c39c27f55264f2bf5fd4ca05b23ad8 to your computer and use it in GitHub Desktop.
description
## Custom name registering / multiple services
You can register the service using a name other than the default name `memcache`.
```php
$app->register(new MemcachedServiceProvider('my.custom.name'));
```
The same method can be used to register multiple services on your application.
If you do, make sure to also use different cache prefixes for each service.
```php
$app->register(new MemcachedServiceProvider('cache1'), array('memcached.prefix' => 'cache1'));
$app->register(new MemcachedServiceProvider('cache2'), array('memcached.prefix' => 'cache2'));
// usage
$app['cache1']->set('foo', 'bar');
$app['cache2']->set('foo', 'baz');
$app['cache1']->get('foo');
$app['cache2']->get('foo');
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment