get the memorycache factory from OCP\Server instead of a cache instance

this allows apps to specify a prefix to use
This commit is contained in:
Robin Appelman 2014-01-08 15:18:12 +01:00
parent 4d65a80892
commit be7837402d
2 changed files with 22 additions and 6 deletions

View File

@ -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');
}
/**

View File

@ -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 = '');
}