We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41332
    • 5 Posts
    We are using modx revolution 2.1 with memcache enabled for resources only.

    We've noticed that updating or adding any field for any Context Setting in manager, causes MODX to flush the whole memcache storage, assuming 'flush_all' is sent to memcache. Because the way we are using modx, we are performing a lot of updates to context settings so this is flushing our cache too often and pretty much rendering MODX cache useless.

    Is there a way to disable this flushing of whole cache when updating context settings ??

    Thanks
      • 33968
      • 863 Posts
      How often are your context settings being updated?

      I wasn't aware the whole cache was refreshed when updating a context setting; thought it just refreshed the relevant parts. You could probably modify the 'update' processor to just do this?

      Also, I can't remember but I think there were some serious caching improvements that came in, perhaps after 2.1. An upgrade *might* help you, but just taking a guess there smiley
        • 41332
        • 5 Posts
        At least once a minute , we have hundreds of contexts.

        I guess I am just going to have to dig into the code, anyone have any pointers on which files to look at ?

          • 33968
          • 863 Posts
          Mind if I ask what you are doing that requires such frequent updates? Settings are meant to be just that: settings that are infrequently adjusted, not really meant to be used as temporary storage or variable containers.

          The reason I ask is there might be another approach that won't require context settings (or mods to the caching procedure).
            • 41332
            • 5 Posts
            We are aware of the other options but they would required major rework of the process.
            It's a long story but it's a system we took over and way it was all setup and configured originally requires frequent changes to settings of a context. These frequent changes are due to way certain business process is performed. On top of it we also have tons of contexts.

            I've dug into the code and see that update to any context setting issues a refresh command which in turn flushes resources, db and context_settings
                    if (!empty($updatedSettings)) {
                        $this->modx->cacheManager->refresh(array(
                            'db' => array(),
                            'resource' => array('contexts' => array($this->object->get('key'))),
                            'context_settings' => array('contexts' => array($this->object->get('key'))),
                        ));
                    }


            When memcache is used Refresh method calls clean method which calls flush method and in turn issues just a flush_all to memcache, ignoring all the options passed to refresh method.

            It seems like that functionality for memcache wasn't fully completed

            [ed. note: darkgaro last edited this post 11 years, 7 months ago.]
              • 33968
              • 863 Posts
              I wouldn't say 'not fully completed', just that it has perhaps been designed staying true to how settings are intended to be used. But I don't have any experience with memcache.

              Custom cache handlers appear to be defined in core/xpdo/cache/.

              You could duplicate the xpdomemcache.class.php and modify it to suit your requirements (and perhaps submit it back for inclusion in future versions wink

              You can specify a custom cache handler in the setting mentioned here (I'm assuming it's the name of your custom cache class):
              http://rtfm.modx.com/display/revolution20/Setting+up+Memcache+in+MODX
                • 41332
                • 5 Posts
                It seems like that Refresh functionality is supposed to refresh the cache, :
                http://rtfm.modx.com/display/revolution20/Caching#Caching-UsingmodCacheManager%3A%3Arefresh%28%29%28forMODX2.1andlater%29

                But it doesn't seems to be behaving in such way for memcache, because instead of selectively deleting just cache for one context it flushes cash (memcache) for whole site.

                This is why I am saying that refresh functionality wasn't implemented as intended for memcache.

                  • 41332
                  • 5 Posts
                  Either Way it seems like we are going to have to upgrade to latest.

                  Thanks for you help