API16

API16:JCacheStorageMemcache/getConnection

From Joomla! Documentation

Revision as of 22:39, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== return memcache connection object <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JCacheStorageMemcache/getConnection|Edit Descript...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

return memcache connection object

[Edit Descripton]

Template: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] Template:SeeAlso:JCacheStorageMemcache/getConnection

Examples

<CodeExamplesForm />