CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Multi-Site functionality »
  • using memcache and multi-sites
Pages: [1]

Author Topic: using memcache and multi-sites  (Read 2398 times)

sushil

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 0
    • Art of Living
  • CiviCRM version: 3.2
  • CMS version: Drupal
  • MySQL version: 5.1
  • PHP version: 5.2
using memcache and multi-sites
December 13, 2010, 01:31:33 am
I'm using one instance of memcache for multiple civicrm installs on the same machine.

I saw that should have been fixed as part of CRM-5633: "enable prefix support so multiple installs can share same memcache"
but it is not working. I couldn't find a way to set a prefix for memcache so that the keys don't overlap for multiple installs.

Thanks
Casti

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: using memcache and multi-sites
December 13, 2010, 08:00:40 am

I'm pretty sure, we did not implement the prefix functionality (am double checking with NYSS)

Would be great if AOL could contribute code to do the needful and/or sponsor a fix for this and also the internationalization memcache issue (i suspect its a 10 hour or so gig)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

sushil

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 0
    • Art of Living
  • CiviCRM version: 3.2
  • CMS version: Drupal
  • MySQL version: 5.1
  • PHP version: 5.2
Re: using memcache and multi-sites
December 13, 2010, 10:07:55 am
I put in a simple work around by defining a config in civicrm.setting.php called MEMCACHE_PREFIX, which can be unique by install.
I modified Memcache.php class:

    function __construct( $host      = 'localhost',
                          $port      = 11211,
                          $timeout   = 3600 ) {
        $this->_host    = $host;
        $this->_port    = $port;
        $this->_timeout = $timeout;
       
        $this->_cache = new Memcache( );
       
        if ( ! $this->_cache->connect( $this->_host, $this->_port ) ) {
            // dont use fatal here since we can go in an infinite loop
            echo 'Could not connect to Memcached server';
            CRM_Utils_System::civiExit( );
        }

      $this->_prefix = defined( 'MEMCACHE_PREFIX' ) ? MEMCACHE_PREFIX : '';
    }

    function set( $key, &$value ) {
      $key = $this->_prefix."_".$key;
        if ( ! $this->_cache->set( $key, $value, false, $this->_timeout ) ) {
            return false;
        }
        return true;
    }

    function &get( $key ) {
      $key = $this->_prefix."_".$key;
        $result =& $this->_cache->get( $key );
        return $result;
    }

    function delete( $key ) {
      $key = $this->_prefix."_".$key;
        return $this->_cache->delete( $key );
    }

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Multi-Site functionality »
  • using memcache and multi-sites

This forum was archived on 2017-11-26.