From be7837402d55abc9a6dc801c943c9b642e821dd0 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Wed, 8 Jan 2014 15:18:12 +0100
Subject: [PATCH] get the memorycache factory from OCP\Server instead of a
 cache instance

this allows apps to specify a prefix to use
---
 lib/private/server.php      | 11 +++++------
 lib/public/cachefactory.php | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 6 deletions(-)
 create mode 100644 lib/public/cachefactory.php

diff --git a/lib/private/server.php b/lib/private/server.php
index 6b242bddd0..b5fa914862 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -136,10 +136,9 @@ class Server extends SimpleContainer implements IServerContainer {
 		$this->registerService('UserCache', function($c) {
 			return new UserCache();
 		});
-		$this->registerService('MemCache', function ($c) {
+		$this->registerService('MemCacheFactory', function ($c) {
 			$instanceId = \OC_Util::getInstanceId();
-			$factory = new \OC\Memcache\Factory($instanceId);
-			return $factory->create();
+			return new \OC\Memcache\Factory($instanceId);
 		});
 		$this->registerService('ActivityManager', function($c) {
 			return new ActivityManager();
@@ -303,10 +302,10 @@ class Server extends SimpleContainer implements IServerContainer {
 	/**
 	 * Returns an ICache instance
 	 *
-	 * @return \OCP\ICache
+	 * @return \OCP\CacheFactory
 	 */
-	function getMemCache() {
-		return $this->query('MemCache');
+	function getMemCacheFactory() {
+		return $this->query('MemCacheFactory');
 	}
 
 	/**
diff --git a/lib/public/cachefactory.php b/lib/public/cachefactory.php
new file mode 100644
index 0000000000..bb49aea7f3
--- /dev/null
+++ b/lib/public/cachefactory.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP;
+
+interface CacheFactory{
+	/**
+	 * @param string $prefix
+	 * @return $return \OCP\ICache
+	 */
+	public function create($prefix = '');
+}
-- 
GitLab