Skip to content

Instantly share code, notes, and snippets.

@sperelson
Created September 11, 2013 20:00
Show Gist options
  • Save sperelson/6528976 to your computer and use it in GitHub Desktop.
Save sperelson/6528976 to your computer and use it in GitHub Desktop.
A Laravel 4.x snippet that will extend the cache driver with a new one that supports AWS ElastiCache. Blogged at http://blog.hapnic.com/2013/09/11/Laravel-4-and-ElastiCache/
<?php
// Register the special elasticache handler here
Cache::extend('elasticache', function() {
require_once(__DIR__.'/../libraries/ElasticacheConnector.php');
$servers = Config::get('cache.memcached');
$elasticache = new Illuminate\Cache\ElasticacheConnector();
$memcached = $elasticache->connect($servers);
return new Illuminate\Cache\Repository(new Illuminate\Cache\MemcachedStore($memcached, Config::get('cache.prefix')));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment