ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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, array, 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 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$keys
Create styles array
The data for the language used.
$server
Definition: getUserInfo.php:12

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(), PHPExcel_Chart_DataSeries\__construct(), CoreTestIterator\__construct(), PHPExcel_Calculation_Database\__fieldExtract(), GuzzleHttp\Psr7\_caseless_remove(), ilObjLanguageExt\_deleteValues(), ilObjLanguageExt\_saveValues(), pdoDB\addPrimaryKey(), getid3_write_id3v2\array_join_merge(), MDB2_Extended\autoExecute(), ilDBPdo\autoExecute(), IMSGlobal\LTI\OAuth\OAuthUtil\build_http_query(), OAuthUtil\build_http_query(), soap_parser\buildVal(), ilAssLacOrderingResultExpression\checkResult(), sspmod_saml_Message\checkSign(), sspmod_saml_Message\decryptAssertion(), sspmod_saml_IdP_SAML2\encryptAssertion(), ilObjTestGUI\fetchAuthoringQuestionIdParameter(), HTMLPurifier_Language\formatMessage(), PHPExcel_Calculation_MathTrig\GCD(), PHPExcel_Properties\getArrayElementsValue(), assClozeGap\getBestSolutionIndexes(), sspmod_saml_Message\getDecryptionKeys(), sspmod_saml_Message\getEncryptionKey(), ilHttpRequestsLanguageDetector\getIso2LanguageCode(), ilAccessKey\getKeys(), PHPExcel_Chart_DataSeries\getPlotCategoryByIndex(), PHPExcel_Chart_DataSeries\getPlotLabelByIndex(), PHPExcel_Chart_DataSeries\getPlotValuesByIndex(), assSingleChoiceGUI\getPreview(), assMultipleChoiceGUI\getPreview(), assKprimChoiceGUI\getPreview(), getServerKeys(), assSingleChoiceGUI\getSolutionOutput(), assMultipleChoiceGUI\getSolutionOutput(), assKprimChoiceGUI\getSolutionOutput(), 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(), MDB2_Driver_mysql\replace(), MDB2_Driver_mysqli\replace(), ilObjLanguageExtGUI\saveObject(), HTMLPurifier_HTMLDefinition\setupConfigStuff(), MDB2\singleton(), ilBadgeAssignment\store(), ilMDClassification\toXML(), SAML2\Assertion\Transformer\DecodeBase64Transformer\transform(), ilExAssignmentMemberStatus\update(), and ilObjLanguageExtGUI\viewObject().

◆ $skipped

$skipped = 0

Definition at line 61 of file memcacheSync.php.

◆ $stats

◆ $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.