Actions

API16

JCacheStorageMemcache/getConnection

From Joomla! Documentation

< API16:JCacheStorageMemcache
Revision as of 17:39, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

[Edit Descripton]

Description:JCacheStorageMemcache/getConnection

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;
}

[Edit See Also] SeeAlso:JCacheStorageMemcache/getConnection

Examples

<CodeExamplesForm />