ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
memcacheSync.php File Reference

Go to the source code of this file.

Functions

if($skipped > 0) if($warnServerDown > 0) if($warnBigSlab > 0) getServerKeys ($server)
 Fetch all keys available in an server. More...
 

Variables

if(!class_exists('Memcache') &&!class_exists('Memcached')) $baseDir = dirname(dirname(__FILE__))
 
 $configdir = SimpleSAML\Utils\Config::getConfigDir()
 
 $warnServerDown = 0
 
 $warnBigSlab = 0
 
 $stats = SimpleSAML_Memcache::getRawStats()
 
 $keys = array()
 
 foreach ( $stats as $group)
 
 $skipped = 0
 
 $sync = 0
 

Function Documentation

◆ getServerKeys()

if ( $skipped > 0) if ( $warnServerDown > 0) if ( $warnBigSlab > 0) getServerKeys (   $server)

Fetch all keys available in an server.

Parameters
string$serverThe server, as a string with <hostname>:<port>.
Returns
array An array with all the keys available on the server.

Definition at line 96 of file memcacheSync.php.

References $GLOBALS, $keys, $server, and exit.

97 {
98  $server = explode(':', $server);
99  $host = $server[0];
100  $port = (int) $server[1];
101 
102  echo("Connecting to: ".$host.":".$port."\n");
103  $socket = fsockopen($host, $port);
104  echo("Connected. Finding keys.\n");
105 
106  if (fwrite($socket, "stats slabs\r\n") === false) {
107  echo("Error requesting slab dump from server.\n");
108  exit(1);
109  }
110 
111  // Read list of slabs
112  $slabs = array();
113  while (($line = fgets($socket)) !== false) {
114  $line = rtrim($line);
115  if ($line === 'END') {
116  break;
117  }
118 
119  if (preg_match('/^STAT (\d+):/', $line, $matches)) {
120  $slab = (int) $matches[1];
121  if (!in_array($slab, $slabs, true)) {
122  $slabs[] = $slab;
123  }
124  }
125  }
126 
127  // Dump keys in slabs
128  $keys = array();
129  foreach ($slabs as $slab) {
130 
131  if (fwrite($socket, "stats cachedump ".$slab." 1000000\r\n") === false) {
132  echo("Error requesting cache dump from server.\n");
133  exit(1);
134  }
135 
136  /* We keep track of the result size, to be able to warn the user if it is
137  * so big that keys may have been lost.
138  */
139  $resultSize = 0;
140 
141  while (($line = fgets($socket)) !== false) {
142  $resultSize += strlen($line);
143 
144  $line = rtrim($line);
145  if ($line === 'END') {
146  break;
147  }
148 
149  if (preg_match('/^ITEM (.*) \[\d+ b; \d+ s\]/', $line, $matches)) {
150  $keys[] = $matches[1];
151  } else {
152  echo("Unknown result from cache dump: ".$line."\n");
153  }
154  }
155  if ($resultSize > 1900000 || count($keys) >= 1000000) {
156  echo("WARNING: Slab ".$slab." on server ".$host.":".$port.
157  " may have contained more keys than we were told about.\n");
158  $GLOBALS['warnBigSlab'] += 1;
159  }
160  }
161 
162  echo("Found ".count($keys)." key(s).\n");
163  fclose($socket);
164 
165  return $keys;
166 }
$keys
$server
Definition: sabredav.php:48
exit
Definition: backend.php:16
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

Variable Documentation

◆ $baseDir

if (!class_exists( 'Memcache') &&!class_exists( 'Memcached')) $baseDir = dirname(dirname(__FILE__))

Definition at line 22 of file memcacheSync.php.

◆ $configdir

$configdir = SimpleSAML\Utils\Config::getConfigDir()

Definition at line 28 of file memcacheSync.php.

◆ $keys

$keys = array()

Definition at line 38 of file memcacheSync.php.

Referenced by HTMLPurifier_ChildDef_Required\__construct(), ilAccessKeyTableGUI\__construct(), PhpOffice\PhpSpreadsheet\Chart\DataSeries\__construct(), CoreTestIterator\__construct(), GuzzleHttp\Psr7\_caseless_remove(), ilObjLanguageExt\_deleteValues(), ilObjLanguageExt\_saveValues(), phpseclib\Net\SSH2\_ssh_agent_login(), pdoDB\addPrimaryKey(), getid3_write_id3v2\array_join_merge(), ilDBPdo\autoExecute(), IMSGlobal\LTI\OAuth\OAuthUtil\build_http_query(), OAuthUtil\build_http_query(), soap_parser\buildVal(), ilAssLacOrderingResultExpression\checkResult(), sspmod_saml_Message\checkSign(), Sabre\CardDAV\Plugin\convertVCard(), sspmod_saml_Message\decryptAssertion(), sspmod_saml_Message\decryptAttributes(), PhpOffice\PhpSpreadsheet\Collection\Memory\deleteMultiple(), sspmod_saml_IdP_SAML2\encryptAssertion(), Monolog\Handler\Slack\SlackRecord\excludeFields(), ilObjTestGUI\fetchAuthoringQuestionIdParameter(), HTMLPurifier_Language\formatMessage(), Jumbojett\OpenIDConnectClient\get_key_for_header(), PhpOffice\PhpSpreadsheet\Chart\Properties\getArrayElementsValue(), assClozeGap\getBestSolutionIndexes(), sspmod_saml_Message\getDecryptionKeys(), sspmod_saml_Message\getEncryptionKey(), PhpOffice\PhpSpreadsheet\Calculation\Database\DatabaseAbstract\getFilteredColumn(), ilHttpRequestsLanguageDetector\getIso2LanguageCode(), ilAccessKey\getKeys(), PhpOffice\PhpSpreadsheet\Collection\Memory\getMultiple(), PhpOffice\PhpSpreadsheet\Chart\DataSeries\getPlotCategoryByIndex(), PhpOffice\PhpSpreadsheet\Chart\DataSeries\getPlotLabelByIndex(), PhpOffice\PhpSpreadsheet\Chart\DataSeries\getPlotValuesByIndex(), assSingleChoiceGUI\getPreview(), assMultipleChoiceGUI\getPreview(), assKprimChoiceGUI\getPreview(), getServerKeys(), assSingleChoiceGUI\getSolutionOutput(), assMultipleChoiceGUI\getSolutionOutput(), assKprimChoiceGUI\getSolutionOutput(), PhpOffice\PhpSpreadsheet\Shared\OLE\getStream(), assKprimChoiceGUI\getTestOutput(), assSingleChoiceGUI\getTestOutput(), assMultipleChoiceGUI\getTestOutput(), League\Flysystem\Plugin\ListWith\handle(), League\Flysystem\Plugin\GetWithMetadata\handle(), ilObjUserGUI\initCreate(), ilObjectGUI\initDidacticTemplate(), getid3_write_id3v2\is_hash(), League\Flysystem\MountManager\listWith(), SAML2\Certificate\KeyLoader\loadKeysFromConfiguration(), SimpleSAML\Utils\Crypto\loadPublicKey(), ilPersonalDesktopGUI\multiarray_sort(), HTMLPurifier_VarParser\parse(), HTMLPurifier_VarParser_Flexible\parseImplementation(), ilTestSequence\pcArrayShuffle(), assQuestion\pcArrayShuffle(), ilObjTest\pcArrayShuffle(), sspmod_saml_Message\processAssertion(), Twig_Tests_Extension_CoreTest\provideArrayKeyCases(), Twig_Tests_Extension_CoreTest\provideInFilterCases(), Twig_Tests_Extension_CoreTest\provideSliceFilterCases(), ilTimelineGUI\render(), ilMultipleNestedOrderingElementsInputGUI\renderMainList(), ilObjLanguageExtGUI\saveObject(), HTMLPurifier_HTMLDefinition\setupConfigStuff(), ilBadgeAssignment\store(), Sabre\DAVACL\PrincipalTest\testGetProperties(), Sabre\CalDAV\PluginTest\testMkCalendarEmptyBodySucceed(), Sabre\CalDAV\PluginTest\testMkCalendarSucceed(), ilMDClassification\toXML(), SAML2\Assertion\Transformer\DecodeBase64Transformer\transform(), ilExAssignmentMemberStatus\update(), and ilObjLanguageExtGUI\viewObject().

◆ $skipped

$skipped = 0

Definition at line 61 of file memcacheSync.php.

◆ $stats

Definition at line 36 of file memcacheSync.php.

◆ $sync

◆ $warnBigSlab

$warnBigSlab = 0

Definition at line 33 of file memcacheSync.php.

◆ $warnServerDown

$warnServerDown = 0

Definition at line 32 of file memcacheSync.php.

◆ foreach

foreach($keys as $key)

Definition at line 39 of file memcacheSync.php.