From b8b4df5425e25403e77b108333faa2251b1348b3 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 9 Jan 2015 18:31:39 +0100 Subject: Cache responses from the AppStore server Otherwise every time the AppStore was opened a lot of connections to the AppStore server were made which resulted in a terrible performance. This changeset will cache the response for a sensible time so that only the first request will be somewhat slow. Performance changes: - Loading a category took previously more than 3 seconds on my machine. Now for every follow-up request it takes less than 200ms, resulting in a performance gain of 1950% - Loading the category list took previously about 750ms - now it takes 154ms, a total performance gain of 395% --- settings/ajax/disableapp.php | 4 ++++ settings/ajax/enableapp.php | 3 +++ settings/ajax/installapp.php | 3 +++ settings/ajax/uninstallapp.php | 3 +++ 4 files changed, 13 insertions(+) (limited to 'settings/ajax') diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php index c1e5bc8eac7..1a133ea9af7 100644 --- a/settings/ajax/disableapp.php +++ b/settings/ajax/disableapp.php @@ -10,5 +10,9 @@ if (!array_key_exists('appid', $_POST)) { $appId = $_POST['appid']; $appId = OC_App::cleanAppId($appId); +// FIXME: Clear the cache - move that into some sane helper method +\OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0'); +\OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1'); + OC_App::disable($appId); OC_JSON::success(); diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index 81ca1e0338d..88abff487db 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -7,6 +7,9 @@ $groups = isset($_POST['groups']) ? $_POST['groups'] : null; try { OC_App::enable(OC_App::cleanAppId($_POST['appid']), $groups); + // FIXME: Clear the cache - move that into some sane helper method + \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0'); + \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1'); OC_JSON::success(); } catch (Exception $e) { OC_Log::write('core', $e->getMessage(), OC_Log::ERROR); diff --git a/settings/ajax/installapp.php b/settings/ajax/installapp.php index 80bc1819724..f25e68214a7 100644 --- a/settings/ajax/installapp.php +++ b/settings/ajax/installapp.php @@ -12,6 +12,9 @@ $appId = OC_App::cleanAppId($appId); $result = OC_App::installApp($appId); if($result !== false) { + // FIXME: Clear the cache - move that into some sane helper method + \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0'); + \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1'); OC_JSON::success(array('data' => array('appid' => $appId))); } else { $l = \OC::$server->getL10N('settings'); diff --git a/settings/ajax/uninstallapp.php b/settings/ajax/uninstallapp.php index cae7c33f292..e50fc31a449 100644 --- a/settings/ajax/uninstallapp.php +++ b/settings/ajax/uninstallapp.php @@ -12,6 +12,9 @@ $appId = OC_App::cleanAppId($appId); $result = OC_App::removeApp($appId); if($result !== false) { + // FIXME: Clear the cache - move that into some sane helper method + \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0'); + \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1'); OC_JSON::success(array('data' => array('appid' => $appId))); } else { $l = \OC::$server->getL10N('settings'); -- cgit v1.2.3