Actions

API16

JCacheStorageMemcache/getConnection

From Joomla! Documentation

< API16:JCacheStorageMemcache
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

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

<CodeExamplesForm />