Page MenuHomePhabricator

D21280.id50674.diff
No OneTemporary

D21280.id50674.diff

diff --git a/resources/sql/autopatches/20200520.inline.01.remcache.sql b/resources/sql/autopatches/20200520.inline.01.remcache.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20200520.inline.01.remcache.sql
@@ -0,0 +1 @@
+DROP TABLE {$NAMESPACE}_differential.differential_changeset_parse_cache;
diff --git a/resources/sql/autopatches/20200520.inline.02.addcache.sql b/resources/sql/autopatches/20200520.inline.02.addcache.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20200520.inline.02.addcache.sql
@@ -0,0 +1,7 @@
+CREATE TABLE {$NAMESPACE}_differential.differential_changeset_parse_cache (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ cacheIndex BINARY(12) NOT NULL,
+ cache LONGBLOB NOT NULL,
+ dateCreated INT UNSIGNED NOT NULL,
+ UNIQUE KEY `key_cacheIndex` (cacheIndex)
+) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php
--- a/src/applications/differential/parser/DifferentialChangesetParser.php
+++ b/src/applications/differential/parser/DifferentialChangesetParser.php
@@ -295,8 +295,6 @@
* By default, there is no render cache key and parsers do not use the cache.
* This is appropriate for rarely-viewed changesets.
*
- * NOTE: Currently, this key must be a valid Differential Changeset ID.
- *
* @param string Key for identifying this changeset in the render cache.
* @return this
*/
@@ -376,9 +374,9 @@
$conn_r = $changeset->establishConnection('r');
$data = queryfx_one(
$conn_r,
- 'SELECT * FROM %T WHERE id = %d',
- $changeset->getTableName().'_parse_cache',
- $render_cache_key);
+ 'SELECT * FROM %T WHERE cacheIndex = %s',
+ DifferentialChangeset::TABLE_CACHE,
+ PhabricatorHash::digestForIndex($render_cache_key));
if (!$data) {
return false;
@@ -480,12 +478,12 @@
try {
queryfx(
$conn_w,
- 'INSERT INTO %T (id, cache, dateCreated) VALUES (%d, %B, %d)
+ 'INSERT INTO %T (cacheIndex, cache, dateCreated) VALUES (%s, %B, %d)
ON DUPLICATE KEY UPDATE cache = VALUES(cache)',
DifferentialChangeset::TABLE_CACHE,
- $render_cache_key,
+ PhabricatorHash::digestForIndex($render_cache_key),
$cache,
- time());
+ PhabricatorTime::getNow());
} catch (AphrontQueryException $ex) {
// Ignore these exceptions. A common cause is that the cache is
// larger than 'max_allowed_packet', in which case we're better off
diff --git a/src/applications/differential/storage/DifferentialSchemaSpec.php b/src/applications/differential/storage/DifferentialSchemaSpec.php
--- a/src/applications/differential/storage/DifferentialSchemaSpec.php
+++ b/src/applications/differential/storage/DifferentialSchemaSpec.php
@@ -9,7 +9,8 @@
id(new DifferentialRevision())->getApplicationName(),
DifferentialChangeset::TABLE_CACHE,
array(
- 'id' => 'id',
+ 'id' => 'auto',
+ 'cacheIndex' => 'bytes12',
'cache' => 'bytes',
'dateCreated' => 'epoch',
),
@@ -18,7 +19,11 @@
'columns' => array('id'),
'unique' => true,
),
- 'dateCreated' => array(
+ 'key_cacheIndex' => array(
+ 'columns' => array('cacheIndex'),
+ 'unique' => true,
+ ),
+ 'key_created' => array(
'columns' => array('dateCreated'),
),
),
diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
--- a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
+++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
@@ -547,8 +547,6 @@
$changeset->setFilename($context->getFilename());
- // TODO: This isn't cached!
-
$viewstate = new PhabricatorChangesetViewState();
$parser = id(new DifferentialChangesetParser())
@@ -556,6 +554,15 @@
->setViewstate($viewstate)
->setChangeset($changeset);
+ $fragment = $inline->getInlineCommentCacheFragment();
+ if ($fragment !== null) {
+ $cache_key = sprintf(
+ '%s.suggestion-view(v1, %s)',
+ $fragment,
+ PhabricatorHash::digestForIndex($new_lines));
+ $parser->setRenderCacheKey($cache_key);
+ }
+
$renderer = new DifferentialChangesetOneUpRenderer();
$renderer->setSimpleMode(true);
@@ -572,6 +579,4 @@
return $view;
}
-
-
}

File Metadata

Mime Type
text/plain
Expires
Tue, May 14, 6:38 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6278083
Default Alt Text
D21280.id50674.diff (4 KB)

Event Timeline