Skip to content

Instantly share code, notes, and snippets.

@CauanCabral
Last active August 29, 2015 13:59
Show Gist options
  • Save CauanCabral/10676660 to your computer and use it in GitHub Desktop.
Save CauanCabral/10676660 to your computer and use it in GitHub Desktop.
Pequeno teste para checar o compartilhamento de informação estática entre processos/requisições
<?php
class MyStat {
protected static $_data = ['initial' => 'default'];
public static function set($key, $value) {
self::$_data[$key] = $value;
}
public static function get($key) {
if (isset(self::$_data[$key])) {
return self::$_data[$key];
}
return 'NaN';
}
}
echo "Memcached is ", (extension_loaded('memcached') ? "enabled" : "disabled"), "<br>";
if (isset($_GET['key'])) {
echo MyStat::get($_GET['key']), '<br>';
if (isset($_GET['value'])) {
MyStat::set($_GET['key'], $_GET['value']);
echo 'Setted "', $_GET['key'], '" as ', $_GET['value'], "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment