API15

JCacheStorageMemcache/getConnection

< API15:JCacheStorageMemcache

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

return memcache connection object

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

& getConnection()


Returns

object memcache connection object

Defined in

libraries/joomla/cache/storage/memcache.php

Importing

jimport( 'joomla.cache.storage.memcache' );

Source Body

function &getConnection() {
        static $db = null;
        if(is_null($db)) {
                $params =& JCacheStorageMemcache::getConfig();
                $persistent     = (isset($params['persistent'])) ? $params['persistent'] : false;
                // This will be an array of loveliness
                $servers        = (isset($params['servers'])) ? $params['servers'] : array();

                // Create the memcache connection
                $db = new Memcache;
                foreach($servers AS $server) {
                        $db->addServer($server['host'], $server['port'], $persistent);
                }
        }
        return $db;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples


Advertisement