46    public static function get(
$key)
 
   57        foreach (self::getMemcacheServers() as 
$server) {
 
   59            if ($serializedInfo === 
false) {
 
   71            $info = unserialize($serializedInfo);
 
   78            if (!is_array(
$info)) {
 
   80                    'Retrieved invalid data from a memcache server. Data was not an array.' 
   84            if (!array_key_exists(
'timestamp', 
$info)) {
 
   86                    'Retrieved invalid data from a memcache server. Missing timestamp.' 
   90            if (!array_key_exists(
'data', 
$info)) {
 
   92                    'Retrieved invalid data from a memcache server. Missing data.' 
   97            if ($latestInfo === 
null) {
 
   99                $latestInfo = $serializedInfo;
 
  100                $latestTime = 
$info[
'timestamp'];
 
  101                $latestData = 
$info[
'data'];
 
  105            if (
$info[
'timestamp'] === $latestTime && $serializedInfo === $latestInfo) {
 
  114            if ($latestTime < 
$info[
'timestamp']) {
 
  115                $latestInfo = $serializedInfo;
 
  116                $latestTime = 
$info[
'timestamp'];
 
  117                $latestData = 
$info[
'data'];
 
  121        if ($latestData === 
null) {
 
  153            'timestamp' => microtime(
true),
 
  161        $savedInfoSerialized = serialize($savedInfo);
 
  164        foreach (self::getMemcacheServers() as 
$server) {
 
  165            if (self::$extension === 
'memcached') {
 
  180    public static function delete(
$key)
 
  182        assert(
'is_string($key)');
 
  186        foreach (self::getMemcacheServers() as 
$server) {
 
  218        if (!array_key_exists(
'hostname', 
$server)) {
 
  220                "hostname setting missing from server in the 'memcache_store.servers' configuration option." 
  224        $hostname = 
$server[
'hostname'];
 
  227        if (!is_string($hostname)) {
 
  229                "Invalid hostname for server in the 'memcache_store.servers' configuration option. The hostname is".
 
  230                ' supposed to be a string.' 
  236        if (strpos($hostname, 
'unix:///') === 0) {
 
  244        } elseif (array_key_exists(
'port', 
$server)) {
 
  247            if (($port <= 0) || ($port > 65535)) {
 
  249                    "Invalid port for server in the 'memcache_store.servers' configuration option. The port number".
 
  250                    ' is supposed to be an integer between 0 and 65535.' 
  255            $port = (int) ini_get(
'memcache.default_port');
 
  256            if ($port <= 0 || $port > 65535) {
 
  263        if (array_key_exists(
'weight', 
$server)) {
 
  265            $weight = (int) 
$server[
'weight'];
 
  268                    "Invalid weight for server in the 'memcache_store.servers' configuration option. The weight is".
 
  269                    ' supposed to be a positive integer.' 
  278        if (array_key_exists(
'timeout', 
$server)) {
 
  280            $timeout = (int) 
$server[
'timeout'];
 
  283                    "Invalid timeout for server in the 'memcache_store.servers' configuration option. The timeout is".
 
  284                    ' supposed to be a positive integer.' 
  293        if (self::$extension === 
'memcached') {
 
  296            $memcache->addServer($hostname, $port, 
true, $weight, $timeout, $timeout, 
true);
 
  313        $class = class_exists(
'Memcache') ? 
'Memcache' : (class_exists(
'Memcached') ? 
'Memcached' : FALSE);
 
  315            throw new Exception(
'Missing Memcached implementation. You must install either the Memcache or Memcached extension.');
 
  317        self::$extension = strtolower($class);
 
  327                    "Invalid index on element in the 'memcache_store.servers' configuration option. Perhaps you".
 
  328                    ' have forgotten to add an array(...) around one of the server groups? The invalid index was: '.
 
  336                    'Invalid value for the server with index '.
$index.
 
  337                    '. Remeber that the \'memcache_store.servers\' configuration option'.
 
  338                    ' contains an array of arrays of arrays.' 
  360        if (self::$serverGroups != 
null) {
 
  365        self::$serverGroups = array();
 
  371        $groups = 
$config->getArray(
'memcache_store.servers');
 
  374        foreach ($groups as 
$index => $group) {
 
  378                    "Invalid index on element in the 'memcache_store.servers'".
 
  379                    ' configuration option. Perhaps you have forgotten to add an array(...)'.
 
  380                    ' around one of the server groups? The invalid index was: '.
$index 
  388            if (!is_array($group)) {
 
  390                    "Invalid value for the server with index ".
$index.
 
  391                    ". Remeber that the 'memcache_store.servers' configuration option".
 
  392                    ' contains an array of arrays of arrays.' 
  428                "The value of 'memcache_store.expires' in the configuration can't be a negative integer." 
  442        $expireTime = time() + 
$expire;
 
  459        foreach (self::getMemcacheServers() as $sg) {
 
  460            $stats = method_exists($sg, 
'getExtendedStats') ? $sg->getExtendedStats() : $sg->getStats();
 
  462                if (
$data === 
false) {
 
  463                    throw new Exception(
'Failed to get memcache server status.');
 
  486        foreach (self::getMemcacheServers() as $sg) {
 
  487            $stats = method_exists($sg, 
'getExtendedStats') ? $sg->getExtendedStats() : $sg->getStats();
 
An exception for terminatinating execution or to throw for unit testing.
static transpose($array)
This function transposes a two-dimensional array, so that $a['k1']['k2'] becomes $a['k2']['k1'].
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static getMemcacheServers()
This function gets a list of all configured memcache servers.
static loadMemcacheServerGroup(array $group)
This function takes in a list of servers belonging to a group and creates a Memcache object from the ...
static set($key, $value, $expire=null)
Save a key-value pair to the memcache servers.
static getRawStats()
Retrieve statistics directly in the form returned by getExtendedStats, for all server groups.
static getExpireTime()
This is a helper-function which returns the expire value of data we should store to the memcache serv...
static addMemcacheServer($memcache, $server)
This function adds a server from the 'memcache_store.servers' configuration option to a Memcache obje...
static getStats()
This function retrieves statistics about all memcache server groups.
foreach($authData as $name=> $values) $memcache