Auth_OpenID_MemcachedStore::getAssociation PHP Method

getAssociation() public method

Read association from memcached. If no handle given and multiple associations found, returns latest issued
public getAssociation ( $server_url, $handle = null )
    function getAssociation($server_url, $handle = null)
    {
        // simple case: handle given
        if ($handle !== null) {
            // get association, return null if failed
            $association = $this->connection->get($this->associationKey($server_url, $handle));
            return $association ? $association : null;
        }
        // no handle given, working with list
        // create key for list of associations
        $serverKey = $this->associationServerKey($server_url);
        // get list of associations
        $serverAssociations = $this->connection->get($serverKey);
        // return null if failed or got empty list
        if (!$serverAssociations) {
            return null;
        }
        // get key of most recently issued association
        $keys = array_keys($serverAssociations);
        sort($keys);
        $lastKey = $serverAssociations[array_pop($keys)];
        // get association, return null if failed
        $association = $this->connection->get($lastKey);
        return $association ? $association : null;
    }