dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b682500
)
Add in-process caching to User::idFromName
author
Andrew Garrett
<werdna@users.mediawiki.org>
Fri, 26 Jun 2009 14:28:25 +0000
(14:28 +0000)
committer
Andrew Garrett
<werdna@users.mediawiki.org>
Fri, 26 Jun 2009 14:28:25 +0000
(14:28 +0000)
includes/User.php
patch
|
blob
|
history
diff --git
a/includes/User.php
b/includes/User.php
index
5849ec0
..
689c580
100644
(file)
--- a/
includes/User.php
+++ b/
includes/User.php
@@
-456,14
+456,29
@@
class User {
# Illegal name
return null;
}
+
+ static $cache = array();
+
+ if ( isset($cache[$name]) ) {
+ return $cache[$name];
+ }
+
$dbr = wfGetDB( DB_SLAVE );
$s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ );
if ( $s === false ) {
-
return
0;
+
$result =
0;
} else {
-
return
$s->user_id;
+
$result =
$s->user_id;
}
+
+ $cache[$name] = $result;
+
+ if ( count($cache) > 1000 ) {
+ $cache = array();
+ }
+
+ return $result;
}
/**