<?php

namespace PPP\Wikidata;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\MemcachedCache;
use Memcached;
use PPP\Module\ModuleEntryPoint;

require_once(__DIR__ . '/../vendor/autoload.php');

//TODO: configuration system?
$cache = new ArrayCache();

if(class_exists('Memcached')) {
	$memcached = new Memcached();
	if($memcached->addServer('localhost', 11211)) {
		$cache = new MemcachedCache();
		$cache->setMemcached($memcached);
	}
}

$entryPoint = new ModuleEntryPoint(new WikidataRequestHandler(
	'https://www.wikidata.org/w/api.php',
	'https://wdq.wmflabs.org/api',
	$cache
));
$entryPoint->exec();

<?php

namespace PPP\Wikidata;

use Doctrine\Common\Cache\ArrayCache;
use PPP\Module\ModuleEntryPoint;

require_once(__DIR__ . '/../vendor/autoload.php');


$entryPoint = new ModuleEntryPoint(new WikidataRequestHandler(
	'https://www.wikidata.org/w/api.php',
	'https://wdq.wmflabs.org/api',
	new ArrayCache()
));
$entryPoint->exec();

--- 
+++ 
@@ -3,14 +3,26 @@
 namespace PPP\Wikidata;
 
 use Doctrine\Common\Cache\ArrayCache;
+use Doctrine\Common\Cache\MemcachedCache;
+use Memcached;
 use PPP\Module\ModuleEntryPoint;
 
 require_once(__DIR__ . '/../vendor/autoload.php');
 
+//TODO: configuration system?
+$cache = new ArrayCache();
+
+if(class_exists('Memcached')) {
+	$memcached = new Memcached();
+	if($memcached->addServer('localhost', 11211)) {
+		$cache = new MemcachedCache();
+		$cache->setMemcached($memcached);
+	}
+}
 
 $entryPoint = new ModuleEntryPoint(new WikidataRequestHandler(
 	'https://www.wikidata.org/w/api.php',
 	'https://wdq.wmflabs.org/api',
-	new ArrayCache()
+	$cache
 ));
 $entryPoint->exec();
Use Memcached on localhost as default (and ArrayCache as fallback)

Note: pretty bad. We should write a proper configuration system.
