r74070 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74069‎ | r74070 | r74071 >
Date:14:48, 1 October 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Followup r70827, use count against getAuthorList, saves caching extra data, and means results don't vary between getAuthorCount and getAuthorList
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRepository.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRepository.php
@@ -128,28 +128,7 @@
129129 }
130130
131131 public function getAuthorCount() {
132 - global $wgMemc;
133 - $key = wfMemcKey( 'codereview', 'authorcount', $this->getId() );
134 - $authorsCount = $wgMemc->get( $key );
135 - if ( is_int( $authorsCount ) ) {
136 - return $authorsCount;
137 - }
138 - $dbr = wfGetDB( DB_SLAVE );
139 - $row = $dbr->select(
140 - 'code_authors',
141 - array( 'COUNT(cr_author) AS author_count' ),
142 - array( 'cr_repo_id' => $this->getId() ),
143 - __METHOD__
144 - );
145 -
146 - if ( !$row ) {
147 - throw new MWException( 'Failed to load expected author count' );
148 - }
149 -
150 - $authorsCount = intval( $row->author_count );
151 -
152 - $wgMemc->set( $key, $authorsCount, 3600 * 24 );
153 - return $authorsCount;
 132+ return count( $this->getAuthorList() );
154133 }
155134
156135 public function getTagList() {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70827Add a caching getAuthorCount, not used, as client side array counting will be...reedy15:44, 10 August 2010

Comments

#Comment by Platonides (talk | contribs)   20:59, 1 October 2010

I would also cache the author list inside the object, so you don't need to go to memcached on getAuthorCount() just after you called getAuthorCount().

Status & tagging log