MDL-38565 cache: tidy up pre-integration

Conflicts:
	lib/db/upgrade.php
This commit is contained in:
Sam Hemelryk
2013-04-19 10:11:38 +12:00
parent 1a038ed7d9
commit 6318a38885
4 changed files with 17 additions and 11 deletions
+1 -1
View File
@@ -314,7 +314,7 @@ class cache_definition {
$requiremultipleidentifiers = false;
$requirelockingread = false;
$requirelockingwrite = false;
$requiresearchable = ($mode === cache_store::MODE_SESSION) ? true : false;;
$requiresearchable = ($mode === cache_store::MODE_SESSION) ? true : false;
$maxsize = null;
$overrideclass = null;
$overrideclassfile = null;
+3 -1
View File
@@ -596,8 +596,10 @@ class cache_helper {
}
$definition = $factory->create_definition($definitionarray['component'], $definitionarray['area']);
$stores = $config->get_stores_for_definition($definition);
// Turn them into store instances.
$stores = self::initialise_cachestore_instances($stores, $definition);
// Initialise all of the stores used for that definition.
foreach (self::initialise_cachestore_instances($stores, $definition) as $store) {
foreach ($stores as $store) {
// If the store doesn't support searching we can skip it.
if (!($store instanceof cache_is_searchable)) {
debugging('Cache stores used for session definitions should ideally be searchable.', DEBUG_DEVELOPER);
+11 -7
View File
@@ -752,7 +752,7 @@ class cache implements cache_loader {
public function delete($key, $recurse = true) {
$parsedkey = $this->parse_key($key);
$this->delete_from_persist_cache($parsedkey);
if ($recurse && !empty($this->loader)) {
if ($recurse && $this->loader !== false) {
// Delete from the bottom of the stack first.
$this->loader->delete($key, $recurse);
}
@@ -774,7 +774,7 @@ class cache implements cache_loader {
$this->delete_from_persist_cache($parsedkey);
}
}
if ($recurse && !empty($this->loader)) {
if ($recurse && $this->loader !== false) {
// Delete from the bottom of the stack first.
$this->loader->delete_many($keys, $recurse);
}
@@ -1572,11 +1572,13 @@ class cache_session extends cache {
$new = 0;
}
if ($new !== self::$loadeduserid) {
// The current user doesn't match the tracker userid for this request.
// The current user doesn't match the tracked userid for this request.
if (!is_null(self::$loadeduserid)) {
// Purge the data we have for the old user.
// This way we don't bloat the session.
$this->purge();
// Update the session id just in case!
$this->sessionid = session_id();
}
self::$loadeduserid = $new;
$this->currentuserid = $new;
@@ -1584,6 +1586,8 @@ class cache_session extends cache {
// The current user matches the loaded user but not the user last used by this cache.
$this->purge();
$this->currentuserid = $new;
// Update the session id just in case!
$this->sessionid = session_id();
}
}
@@ -1863,11 +1867,11 @@ class cache_session extends cache {
public function purge() {
// 1. Purge the session object.
$this->session = array();
// 2. Purge the store.
$this->get_store()->purge();
// 3. Optionally pruge any stacked loaders.
// 2. Delete the record for this users session from the store.
$this->get_store()->delete($this->sessionid);
// 3. Optionally purge any stacked loaders in the same way.
if ($this->get_loader()) {
$this->get_loader()->purge();
$this->get_loader()->delete($this->sessionid);
}
return true;
}
+2 -2
View File
@@ -349,14 +349,14 @@ class cache_phpunit_tests extends advanced_testcase {
$this->assertTrue(true);
}
try {
$cache->get_many(array('exception1', 'exception2'), MUST_EXUST);
$cache->get_many(array('exception1', 'exception2'), MUST_EXIST);
$this->fail('Exception expected from cache::get_many using MUST_EXIST');
} catch (Exception $e) {
$this->assertTrue(true);
}
$cache->set('test', 'test');
try {
$cache->get_many(array('test', 'exception'), MUST_EXUST);
$cache->get_many(array('test', 'exception'), MUST_EXIST);
$this->fail('Exception expected from cache::get_many using MUST_EXIST');
} catch (Exception $e) {
$this->assertTrue(true);