diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-27 13:17:04 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-27 13:17:04 +0000 |
commit | ad477373525719a9ee26655f4fd14ebd677de20e (patch) | |
tree | af5ed147919688e78a2f6c4db537373a57f36aed /engine | |
parent | 89d549a501278600ff113428be06bb39263b1bdf (diff) | |
download | elgg-ad477373525719a9ee26655f4fd14ebd677de20e.tar.gz elgg-ad477373525719a9ee26655f4fd14ebd677de20e.tar.bz2 |
Caching datalists. Refs #101
git-svn-id: https://code.elgg.org/elgg/trunk@1178 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/elgglib.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 31693906d..3b8e444d7 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1177,6 +1177,8 @@ /**
* Data lists
*/
+ + $DATALIST_CACHE = array(); /**
* Get the value of a particular piece of data in the datalist
@@ -1186,13 +1188,17 @@ */
function datalist_get($name) {
- global $CONFIG;
+ global $CONFIG, $DATALIST_CACHE;
// We need this, because sometimes datalists are received before the database is created
if (!is_db_installed()) return false;
- $name = sanitise_string($name);
- if ($row = get_data_row("select value from {$CONFIG->dbprefix}datalists where name = '{$name}'")) {
+ $name = sanitise_string($name); + if (isset($DATALIST_CACHE[$name])) + return $DATALIST_CACHE[$name]; +
+ if ($row = get_data_row("select value from {$CONFIG->dbprefix}datalists where name = '{$name}'")) { + $DATALIST_CACHE[$name] = $row->value;
return $row->value;
}
return false;
@@ -1208,11 +1214,16 @@ */
function datalist_set($name, $value) {
- global $CONFIG;
+ global $CONFIG, $DATALIST_CACHE; +
$name = sanitise_string($name);
- $value = sanitise_string($value);
+ $value = sanitise_string($value); +
delete_data("delete from {$CONFIG->dbprefix}datalists where name = '{$name}'");
- insert_data("insert into {$CONFIG->dbprefix}datalists set name = '{$name}', value = '{$value}'");
+ insert_data("insert into {$CONFIG->dbprefix}datalists set name = '{$name}', value = '{$value}'"); + + $DATALIST_CACHE[$name] = $value; +
return true;
}
|