Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorUserCache.php
| Show All 36 Lines | public function save() { | ||||
| return parent::save(); | return parent::save(); | ||||
| } | } | ||||
| public static function writeCache( | public static function writeCache( | ||||
| PhabricatorUserCacheType $type, | PhabricatorUserCacheType $type, | ||||
| $key, | $key, | ||||
| $user_phid, | $user_phid, | ||||
| $raw_value) { | $raw_value) { | ||||
| self::writeCaches( | |||||
| array( | |||||
| array( | |||||
| 'type' => $type, | |||||
| 'key' => $key, | |||||
| 'userPHID' => $user_phid, | |||||
| 'value' => $raw_value, | |||||
| ), | |||||
| )); | |||||
| } | |||||
| public static function writeCaches(array $values) { | |||||
| if (PhabricatorEnv::isReadOnly()) { | if (PhabricatorEnv::isReadOnly()) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (!$values) { | |||||
| return; | |||||
| } | |||||
| $table = new self(); | $table = new self(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| $sql = array(); | |||||
| foreach ($values as $value) { | |||||
| $key = $value['key']; | |||||
| $sql[] = qsprintf( | |||||
| $conn_w, | |||||
| '(%s, %s, %s, %s, %s)', | |||||
| $value['userPHID'], | |||||
| PhabricatorHash::digestForIndex($key), | |||||
| $key, | |||||
| $value['value'], | |||||
| $value['type']->getUserCacheType()); | |||||
| } | |||||
| $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||
| foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { | |||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'INSERT INTO %T (userPHID, cacheIndex, cacheKey, cacheData, cacheType) | 'INSERT INTO %T (userPHID, cacheIndex, cacheKey, cacheData, cacheType) | ||||
| VALUES (%s, %s, %s, %s, %s) | VALUES %Q | ||||
| ON DUPLICATE KEY UPDATE cacheData = VALUES(cacheData)', | ON DUPLICATE KEY UPDATE cacheData = VALUES(cacheData)', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $user_phid, | $chunk); | ||||
| PhabricatorHash::digestForIndex($key), | } | ||||
| $key, | |||||
| $raw_value, | |||||
| $type->getUserCacheType()); | |||||
| unset($unguarded); | unset($unguarded); | ||||
| } | } | ||||
| public static function clearCache($key, $user_phid) { | public static function clearCache($key, $user_phid) { | ||||
| if (PhabricatorEnv::isReadOnly()) { | if (PhabricatorEnv::isReadOnly()) { | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 37 Lines | |||||