Skip to content

Instantly share code, notes, and snippets.

@LoveDuckie
Created February 28, 2022 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LoveDuckie/b2a28fac0bea24dd3f21dacd9951f0d9 to your computer and use it in GitHub Desktop.
Save LoveDuckie/b2a28fac0bea24dd3f21dacd9951f0d9 to your computer and use it in GitHub Desktop.
A configuration snippet for integrating memcached caching support with SliverStripe.
<?php
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Cache\MemcachedCacheFactory;
$cacheClient = new Memcached();
$cacheClient->addServer('your-memcached-server-hostname-goes-here', 11211);
$cacheFactory = new MemcachedCacheFactory($cacheClient);
Injector::inst()->registerService($cacheFactory, "SilverStripe\\Core\\Cache\\CacheFactory");
Injector::inst()->registerService($cacheFactory, "CacheFactory");
Injector::nest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment