Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13995699
D17002.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D17002.diff
View Options
diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php
--- a/src/applications/diffusion/controller/DiffusionController.php
+++ b/src/applications/diffusion/controller/DiffusionController.php
@@ -340,41 +340,60 @@
$drequest = $this->getDiffusionRequest();
$viewer = $this->getViewer();
+ $repository = $drequest->getRepository();
+ $repository_phid = $repository->getPHID();
+ $stable_commit = $drequest->getStableCommit();
- try {
- $result = $this->callConduitWithDiffusionRequest(
- 'diffusion.filecontentquery',
- array(
- 'path' => $readme_path,
- 'commit' => $drequest->getStableCommit(),
- ));
- } catch (Exception $ex) {
- return null;
- }
+ $cache = PhabricatorCaches::getMutableStructureCache();
+ $cache_key = "diffusion".
+ ".repository({$repository_phid})".
+ ".commit({$stable_commit})".
+ ".readme({$readme_path})";
+
+ $readme_cache = $cache->getKey($cache_key);
+ if (!$readme_cache) {
+ try {
+ $result = $this->callConduitWithDiffusionRequest(
+ 'diffusion.filecontentquery',
+ array(
+ 'path' => $readme_path,
+ 'commit' => $drequest->getStableCommit(),
+ ));
+ } catch (Exception $ex) {
+ return null;
+ }
- $file_phid = $result['filePHID'];
- if (!$file_phid) {
- return null;
- }
+ $file_phid = $result['filePHID'];
+ if (!$file_phid) {
+ return null;
+ }
- $file = id(new PhabricatorFileQuery())
- ->setViewer($viewer)
- ->withPHIDs(array($file_phid))
- ->executeOne();
- if (!$file) {
- return null;
- }
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($file_phid))
+ ->executeOne();
+ if (!$file) {
+ return null;
+ }
- $corpus = $file->loadFileData();
+ $corpus = $file->loadFileData();
+
+ $readme_cache = array(
+ 'corpus' => $corpus,
+ );
+
+ $cache->setKey($cache_key, $readme_cache);
+ }
- if (!strlen($corpus)) {
+ $readme_corpus = $readme_cache['corpus'];
+ if (!strlen($readme_corpus)) {
return null;
}
return id(new DiffusionReadmeView())
->setUser($this->getViewer())
->setPath($readme_path)
- ->setContent($corpus);
+ ->setContent($readme_corpus);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 24, 2:52 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711205
Default Alt Text
D17002.diff (2 KB)
Attached To
Mode
D17002: Cache README content for repositories
Attached
Detach File
Event Timeline
Log In to Comment