EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/145749
Change subject: Revert "Revert "Utilize BufferedCache in TreeRepository""
......................................................................
Revert "Revert "Utilize BufferedCache in TreeRepository""
This reverts commit 50dbdb9fb597f342b356209a9fbc82cfa1f5b37f.
When a new revision fails to commit both BufferedCache and the Database
are rolled back, unfortunatly TreeRepository is using a plain
BagOStuff so we can have a situation where a post exists in the
TreeRepository memcache but not in the actual database.
There was some problem with this patch before that caused us to
revert it, but noone remembers what it is. Please test or
try and remember so we can move this forward.
Change-Id: I9ff907e23f4c4e8f8afc5672f1a8f55fed08ea19
---
M container.php
M includes/Repository/MultiGetList.php
M includes/Repository/TreeRepository.php
3 files changed, 34 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/49/145749/1
diff --git a/container.php b/container.php
index 11f3cdc..157f2b4 100644
--- a/container.php
+++ b/container.php
@@ -34,8 +34,7 @@
global $wgFlowCacheTime;
return new Flow\Repository\TreeRepository(
$c['db.factory'],
- $c['memcache'],
- $wgFlowCacheTime
+ $c['memcache.buffered']
);
} );
diff --git a/includes/Repository/MultiGetList.php
b/includes/Repository/MultiGetList.php
index 202029d..69e0b72 100644
--- a/includes/Repository/MultiGetList.php
+++ b/includes/Repository/MultiGetList.php
@@ -2,7 +2,7 @@
namespace Flow\Repository;
-use BagOStuff;
+use Flow\Data\BufferedCache;
use Flow\Model\UUID;
use Flow\Container;
use Flow\Exception\InvalidInputException;
@@ -10,12 +10,15 @@
class MultiGetList {
/**
- * @param BagOStuff $cache
- * @param integer $cacheTime
+ * @var BufferedCache
*/
- public function __construct( BagOStuff $cache, $cacheTime ) {
+ protected $cache;
+
+ /**
+ * @param BufferedCache $cache
+ */
+ public function __construct( BufferedCache $cache ) {
$this->cache = $cache;
- $this->cacheTime = $cacheTime;
}
public function get( $key, array $ids, $loadCallback ) {
@@ -72,7 +75,7 @@
// If we failed contacting memcache a moment ago don't
bother trying to
// push values either.
if ( $multiRes !== false ) {
- $this->cache->set( $invCacheKeys[$id], $row,
$this->cacheTime );
+ $this->cache->set( $invCacheKeys[$id], $row );
}
$result[$id] = $row;
}
diff --git a/includes/Repository/TreeRepository.php
b/includes/Repository/TreeRepository.php
index f0fc433..7a8c025 100644
--- a/includes/Repository/TreeRepository.php
+++ b/includes/Repository/TreeRepository.php
@@ -2,6 +2,7 @@
namespace Flow\Repository;
+use Flow\Data\BufferedCache;
use Flow\Data\ObjectManager;
use Flow\DbFactory;
use Flow\Model\UUID;
@@ -32,17 +33,29 @@
* during a topic split
*/
class TreeRepository {
+
+ /**
+ * @var string
+ */
protected $tableName = 'flow_tree_node';
+
+ /**
+ * @var DbFactory
+ */
+ protected $dbFactory;
+
+ /**
+ * @var BufferedCache
+ */
+ protected $cache;
/**
* @param DbFactory $dbFactory Factory to source connection objects from
* @param BagOStuff $cache
- * @param integer $cacheTime How long to cache data in memcache
*/
- public function __construct( DbFactory $dbFactory, BagOStuff $cache,
$cacheTime = 0 ) {
+ public function __construct( DbFactory $dbFactory, BufferedCache $cache
) {
$this->dbFactory = $dbFactory;
$this->cache = $cache;
- $this->cacheTime = $cacheTime;
}
/**
@@ -69,16 +82,16 @@
$subtreeKey = $this->cacheKey( 'subtree', $descendant );
$parentKey = $this->cacheKey( 'parent', $descendant );
$pathKey = $this->cacheKey( 'rootpath', $descendant );
- $this->cache->set( $subtreeKey, array( $descendant ),
$this->cacheTime );
+ $this->cache->set( $subtreeKey, array( $descendant ) );
if ( $ancestor === null ) {
- $this->cache->set( $parentKey, null, $this->cacheTime );
- $this->cache->set( $pathKey, array( $descendant ),
$this->cacheTime );
+ $this->cache->set( $parentKey, null );
+ $this->cache->set( $pathKey, array( $descendant ) );
$path = array( $descendant );
} else {
- $this->cache->set( $parentKey, $ancestor,
$this->cacheTime );
+ $this->cache->set( $parentKey, $ancestor );
$path = $this->findRootPath( $ancestor );
$path[] = $descendant;
- $this->cache->set( $pathKey, $path, $this->cacheTime );
+ $this->cache->set( $pathKey, $path );
}
$dbw = $this->dbFactory->getDB( DB_MASTER );
@@ -237,7 +250,7 @@
ksort( $path );
$path = array_reverse( $path );
- $this->cache->set( $cacheKeys[$descendantId], $path,
$this->cacheTime );
+ $this->cache->set( $cacheKeys[$descendantId], $path );
}
return $paths + $cacheValues;
@@ -339,7 +352,7 @@
* @return array map from root id to its descendant list
*/
public function fetchSubtreeNodeList( array $roots ) {
- $list = new MultiGetList( $this->cache, $this->cacheTime );
+ $list = new MultiGetList( $this->cache );
$res = $list->get(
array( 'tree', 'subtree' ),
$roots,
@@ -388,7 +401,7 @@
* nodes are not represented in the result set.
*/
public function fetchParentMap( array $nodes ) {
- $list = new MultiGetList( $this->cache, $this->cacheTime );
+ $list = new MultiGetList( $this->cache );
return $list->get(
array( 'tree', 'parent' ),
$nodes,
--
To view, visit https://gerrit.wikimedia.org/r/145749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ff907e23f4c4e8f8afc5672f1a8f55fed08ea19
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits