]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add version and path to cache prefix
authorLukas Reschke <lukas@owncloud.com>
Tue, 17 Mar 2015 10:56:00 +0000 (11:56 +0100)
committerLukas Reschke <lukas@owncloud.com>
Tue, 17 Mar 2015 11:39:49 +0000 (12:39 +0100)
Prevents to have the cache reused by other instances on the server which have possible the same instance ID and also invalidates older cache entries after an upgrade which can cause unwanted side-effects.

Impact for deployment: The same cache will only get used if ownCloud is installed with the same version and under the same path. But this should be a basic requirement anyways.

lib/private/memcache/cache.php
lib/private/server.php

index c606d94fa51d3a47124aec65b980f30f55270835..d2d0353febc17746cbc3d853c14b4f068a3de615 100644 (file)
@@ -21,6 +21,9 @@ abstract class Cache implements \ArrayAccess, \OCP\ICache {
                $this->prefix = $prefix;
        }
 
+       /**
+        * @return string Prefix used for caching purposes
+        */
        public function getPrefix() {
                return $this->prefix;
        }
index 2f688c47f09c6dea95a3acf8a18b525fad62b15d..6261337e0b1e1005e8e108c9a65bb351897f10a4 100644 (file)
@@ -157,8 +157,13 @@ class Server extends SimpleContainer implements IServerContainer {
                });
                $this->registerService('MemCacheFactory', function ($c) {
                        $config = $c->getConfig();
+                       $v = \OC_App::getAppVersions();
+                       $v['core'] = implode('.', \OC_Util::getVersion());
+                       $version = implode(',', $v);
                        $instanceId = \OC_Util::getInstanceId();
-                       return new \OC\Memcache\Factory($instanceId,
+                       $path = \OC::$SERVERROOT;
+                       $prefix = md5($instanceId.'-'.$version.'-'.$path);
+                       return new \OC\Memcache\Factory($prefix,
                                $config->getSystemValue('memcache.local', null),
                                $config->getSystemValue('memcache.distributed', null)
                        );