Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c046cb3

Browse files
committed
Fix cache invalidation
1 parent eb5f974 commit c046cb3

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

core/src/core/classes/class.AuthService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,8 @@ public static function getRole($roleId, $createIfNotExists = false)
11471147
public static function updateRole($roleObject, $userObject = null)
11481148
{
11491149
ConfService::getConfStorageImpl()->updateRole($roleObject, $userObject);
1150-
CacheService::deleteAll(AJXP_CACHE_SERVICE_NS_SHARED);
1150+
//CacheService::deleteAll(AJXP_CACHE_SERVICE_NS_SHARED);
1151+
ConfService::getInstance()->invalidateLoadedRepositories();
11511152
}
11521153
/**
11531154
* Delete a role by its id
@@ -1158,7 +1159,8 @@ public static function updateRole($roleObject, $userObject = null)
11581159
public static function deleteRole($roleId)
11591160
{
11601161
ConfService::getConfStorageImpl()->deleteRole($roleId);
1161-
CacheService::deleteAll(AJXP_CACHE_SERVICE_NS_SHARED);
1162+
//CacheService::deleteAll(AJXP_CACHE_SERVICE_NS_SHARED);
1163+
ConfService::getInstance()->invalidateLoadedRepositories();
11621164
}
11631165

11641166
public static function filterPluginParameters($pluginId, $params, $repoId = null)

core/src/core/classes/class.ConfService.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ public function invalidateLoadedRepositories()
599599
{
600600
if(isSet($_SESSION["REPOSITORIES"])) unset($_SESSION["REPOSITORIES"]);
601601
$this->configs["REPOSITORIES"] = null;
602-
CacheService::deleteAll(AJXP_CACHE_SERVICE_NS_SHARED);
602+
CacheService::delete(AJXP_CACHE_SERVICE_NS_SHARED, $this->getRegistryCacheKey(true));
603+
CacheService::delete(AJXP_CACHE_SERVICE_NS_SHARED, $this->getRegistryCacheKey(false));
603604
}
604605

605606
private function cacheRepository($repoId, $repository){
@@ -1007,6 +1008,7 @@ public function addRepositoryInst($oRepository)
10071008
}
10081009
AJXP_Controller::applyHook("workspace.after_create", array($oRepository));
10091010
AJXP_Logger::info(__CLASS__,"Create Repository", array("repo_name"=>$oRepository->getDisplay()));
1011+
CacheService::save(AJXP_CACHE_SERVICE_NS_SHARED, "repository:".$oRepository->getId(), $oRepository);
10101012
$this->invalidateLoadedRepositories();
10111013
return null;
10121014
}
@@ -1134,8 +1136,8 @@ public static function replaceRepository($oldId, $oRepositoryObject)
11341136
}
11351137
/**
11361138
* See static method
1137-
* @param $oldId
1138-
* @param $oRepositoryObject
1139+
* @param string $oldId
1140+
* @param Repository $oRepositoryObject
11391141
* @return int
11401142
*/
11411143
public function replaceRepositoryInst($oldId, $oRepositoryObject)
@@ -1149,6 +1151,7 @@ public function replaceRepositoryInst($oldId, $oRepositoryObject)
11491151
AJXP_Controller::applyHook("workspace.after_update", array($oRepositoryObject));
11501152
AJXP_Logger::info(__CLASS__,"Edit Repository", array("repo_name"=>$oRepositoryObject->getDisplay()));
11511153
$this->invalidateLoadedRepositories();
1154+
CacheService::save(AJXP_CACHE_SERVICE_NS_SHARED, "repository:" . $oRepositoryObject->getId(), $oRepositoryObject);
11521155
return 0;
11531156
}
11541157
/**
@@ -1198,6 +1201,7 @@ public function deleteRepositoryInst($repoId)
11981201
AJXP_Controller::applyHook("workspace.after_delete", array($repoId));
11991202
AJXP_Logger::info(__CLASS__,"Delete Repository", array("repo_id"=>$repoId));
12001203
$this->invalidateLoadedRepositories();
1204+
CacheService::delete(AJXP_CACHE_SERVICE_NS_SHARED, "repository:".$repoId);
12011205
return 0;
12021206
}
12031207

core/src/plugins/access.s3/class.s3CacheService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class s3CacheService implements \Aws\CacheInterface
3131
* @return mixed|null Returns the value or null if not found.
3232
*/
3333
public function get($key) {
34-
return \CacheService::fetch(AJXP_CACHE_SERVICE_NS_SHARED, $key);
34+
return \CacheService::fetch(AJXP_CACHE_SERVICE_NS_NODES, $key);
3535
}
3636

3737
/**
@@ -43,7 +43,7 @@ public function get($key) {
4343
* to 0 to allow an unlimited lifetime.
4444
*/
4545
public function set($key, $value, $ttl = 0) {
46-
\CacheService::save(AJXP_CACHE_SERVICE_NS_SHARED, $key, $value, $ttl);
46+
\CacheService::save(AJXP_CACHE_SERVICE_NS_NODES, $key, $value, $ttl);
4747
}
4848

4949
/**
@@ -52,6 +52,6 @@ public function set($key, $value, $ttl = 0) {
5252
* @param string $key Key to remove.
5353
*/
5454
public function remove($key) {
55-
\CacheService::delete(AJXP_CACHE_SERVICE_NS_SHARED, $key);
55+
\CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, $key);
5656
}
5757
}

core/src/plugins/core.access/src/Stream/PathWrapper.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
class PathWrapper extends AJXP_SchemeTranslatorWrapper
1919
{
2020
const CACHE_KEY='PathWrapperParams';
21-
const CACHE_EXPIRY_TIME = 10000;
2221

2322
/*
2423
* @array localParams
@@ -30,14 +29,13 @@ public static function applyInitPathHook($url, $context = 'core')
3029
$params = [];
3130
$parts = AJXP_Utils::safeParseUrl($url);
3231

33-
if (! ($params = self::getLocalParams(self::CACHE_KEY . $url)) &&
34-
! ($params = CacheService::fetch(AJXP_CACHE_SERVICE_NS_SHARED, self::CACHE_KEY . $url))) {
32+
if (! ($params = self::getLocalParams(self::CACHE_KEY . $url)) ) {
3533

3634
// Nothing in cache
3735
$repositoryId = $parts["host"];
3836
$repository = ConfService::getRepositoryById($parts["host"]);
3937
if ($repository == null) {
40-
throw new Exception("Cannot find repository");
38+
throw new \Exception("Cannot find repository");
4139
}
4240

4341
$configHost = $repository->getOption('HOST');
@@ -61,7 +59,6 @@ public static function applyInitPathHook($url, $context = 'core')
6159
$params['key'] = md5($params['keybase']);
6260

6361
self::addLocalParams(self::CACHE_KEY . $url, $params);
64-
CacheService::save(AJXP_CACHE_SERVICE_NS_SHARED, self::CACHE_KEY . $url, $params, self::CACHE_EXPIRY_TIME);
6562
}
6663

6764
$repoData = self::actualRepositoryWrapperData($parts["host"]);

0 commit comments

Comments
 (0)