@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide a pure APC cache for runtime caching

Summary:
Ref T11954. Depends on D16992. We have some data which can be generated and cached at runtime. Three examples are:

- Class map from Conduit method names to implementing classes.
- Class map from PHID types to implementing classes.
- The main routing map.

None of these are huge wins but they impose global costs and can be shaved down through caching without introducing an enormous amount of new complexity.

The cost to these maps is that sometimes you'll need to restart your webserver, even in development mode if these caches are active. However, in some cases these changes are very rare, and in other cases we can just leave the cache disabled in development mode without a huge complexity cost.

Specifically, the Conduit/PHID type class maps are self-validating and can not go bad, even in development mode.

The routing map will be able to, but I plan to just disable it in development mode.

This provides a general-purpose pure APC cache stack for storing this data.

Test Plan: See future changes.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11954

Differential Revision: https://secure.phabricator.com/D16993

+36
+36
src/applications/cache/PhabricatorCaches.php
··· 117 117 } 118 118 119 119 120 + /* -( Runtime Cache )------------------------------------------------------ */ 121 + 122 + 123 + /** 124 + * Get a runtime cache stack. 125 + * 126 + * This stack is just APC. It's fast, it's effectively immutable, and it 127 + * gets thrown away when the webserver restarts. 128 + * 129 + * This cache is suitable for deriving runtime caches, like a map of Conduit 130 + * method names to provider classes. 131 + * 132 + * @return PhutilKeyValueCacheStack Best runtime stack available. 133 + */ 134 + public static function getRuntimeCache() { 135 + static $cache; 136 + if (!$cache) { 137 + $caches = self::buildRuntimeCaches(); 138 + $cache = self::newStackFromCaches($caches); 139 + } 140 + return $cache; 141 + } 142 + 143 + 144 + private static function buildRuntimeCaches() { 145 + $caches = array(); 146 + 147 + $apc = new PhutilAPCKeyValueCache(); 148 + if ($apc->isAvailable()) { 149 + $caches[] = $apc; 150 + } 151 + 152 + return $caches; 153 + } 154 + 155 + 120 156 /* -( Repository Graph Cache )--------------------------------------------- */ 121 157 122 158