domains = seperate namespaces?

Help
Chris
2005-04-18
2013-06-04
  • Chris
    Chris
    2005-04-18

    i've been developing my PHP applications for awhile now to take full advantage of using mmcache shared memory keys.  Without it the DB server would cripple and die in minutes.
    So i don't know how I didn't notice until now that mmcache takes it upon itself to read the HOST: for a request and isolate the cache namespaces.  I designed everything under the assumption that the cache truely was shared.  I can't find any configuration option to disable this, it SERIOUSLY destroys what i designed.  This means the data cache is being duplicated for every domain/subdomain my software is accessed from, and if something is updated on one, it is incapable of rm'ing all the affected caches.

    I'm lost in the source code,  If anyone can just point me to where the code is that does this, I will hack away at it until my problem is solved.

     
    • Thomas Seifert
      Thomas Seifert
      2005-04-18

      > So i don't know how I didn't notice until now that
      > mmcache takes it upon itself
      > to read the HOST: for a request and isolate the cache namespaces.

      It doesn't.
      Which webserver in which configuration do you use?

       
    • Chris
      Chris
      2005-04-18

      I have tried on two different setups.  On one is php 4.3.9 as a shared module in apache 2.something, with mmcache as a php extension.  On the other machine PHP is statically compiled into apache 1.3.33 with mmcache as a zend extension.

      On both machines, accessing the same script through different vhosts results in seperated caches.

      At first i thought it was the domain, it is by vhost though.

       
    • Chris
      Chris
      2005-04-20

      nope, it is by domain, i am positive, i have tested on two machines

       
    • Chris
      Chris
      2005-04-20

      BAM!

      mmcache.c [3280-3294]
      static char* build_key(const char* key, int key_len, int *xlen TSRMLS_DC) {
        int len = strlen(MMCG(hostname));
        if (len > 0) {
          char* xkey;
          *xlen = len + key_len + 1;
          xkey = emalloc((*xlen)+1);
          memcpy(xkey, MMCG(hostname), len);
          xkey[len] = ':';
          memcpy(xkey+len+1, key, key_len+1);
          return xkey;
        } else {
          *xlen = key_len;
          return (char*)key;
        }
      }

      I just commented like so:

      static char* build_key(const char* key, int key_len, int *xlen TSRMLS_DC) {
        /*int len = strlen(MMCG(hostname));
        if (len > 0) {
          char* xkey;
          *xlen = len + key_len + 1;
          xkey = emalloc((*xlen)+1);
          memcpy(xkey, MMCG(hostname), len);
          xkey[len] = ':';
          memcpy(xkey+len+1, key, key_len+1);
          return xkey;
        } else {*/
          *xlen = key_len;
          return (char*)key;
        /*}*/
      }

      my issue is resolved.  Hope anyone else havin this prob finds this.  ( Keep in mind this could expose sensitive data, know what's on your machine that has access to mmcache )

       
      • Franck
        Franck
        2005-04-20

        should be great you speak of that on eaccelerator forums...

        Regards, franck