We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41592 ☆ A M B ☆
    • 83 Posts
    Hi everybody! I really need help from the community!
    I'm developing a website with some Custom Resource Classes.

    I developed a system with partitioned cache (god bless getCache Extra and opengeek) in order to hold always high speed of page loading (1st request too).
    So, to do that, my Snippets loads custom elements that grabs them directly from cache only (extremely speed).

    The idea is to erase and rewrite the cache partition when those are edited (an approach like: "Save&Build", to avoid for the first request too much loading time and to make high granularity cache building).
    About remove I had no problems, thanks to override function $resource->save() and $resource->remove() I'm able to delete the partitioned cache selected.

    To this end, I would like to update (or better, to rebuild cache of) specific sections of the cache when such sections are changed in the manager (for example following a object save() call).
    In this regard, I created a custom event (onSwingtimeObjEvent) and a plug-in that is activated when the event is invoked (sounds good and works).

    This plugin, based on the data taken during the invocation choose which sections of the cache must be rebuilt and do it (by calling a snippet with runSnippet that write on cacheManager selected section).

    Theoretically, an approach of this kind should be better than calling a CURL on the pages that are affected by this change and therefore need to be updated. is it?

    But where is my problem?? The Plugin!

    When the Event is invoked my plugin failed and wrote in console that there was an error in my custom connector.php ?_? Why?? Why it's involved?

    My custom Plugin is really simple: just call $modx->runSnippet() and put in cacheManager the result, and I don't understand why my connector is involved :|
     [2013-10-19 22:08:58] (ERROR @ /modx228/assets/components/swingtime/connector.php) [onSwingtimeObjEvent]


    $listview=$modx->runSnippet('getCachedListView');
    $modx->cacheManager->set('listview_'.$destinazione->get('id'),$listview,0,array(
                xPDO::OPT_CACHE_KEY => 'swingtime/listView',
                xPDO::OPT_CACHE_HANDLER => 'xPDOFileCache',
                xPDO::OPT_CACHE_EXPIRES => 0
            ));
    


    Any Suggestion? What do you think about this logic of partitioned cache/rebuild script? [ed. note: solidusite last edited this post 12 years, 11 months ago.]
      Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
      • 41592 ☆ A M B ☆
      • 83 Posts
      Despite not having understood the problem of my connector, I think it is related to the call of $modx->runSnippet inside a Plugin that give it to me a blank page after call it sad Any idea?

      By the way for the moment, I currently changed my snippet of front-end delegating the task of rebuilding the cache partition changed to the first visitor (like default modx logic).
      Simply checks whether the item interested is present in the cache, otherwise it generates.
      Everything works great!


      So, from the beginning, I used "GetCache" directly on the snippet that generated a collection of elements (in my case a collection of chunks with xpdoSimpleObject class properties, so additional information for my resources), and was saved the entire snippet in the partitioned cache. Only by using this Extra I gained valuable seconds (from 6sec to 4sec) when the page loads, that cause I split the cache of the resource (template, css, js,phpthumb,etc) from that snippet, and consequently, a refresh of the cache included only a partial generation of the resource and not my snippet too (and viceversa), fantastic.

      Next problem concerned the editing of a single element, that involved the creation of the entire snippet from the beginning (How much code executed for nothing!)

      From here I have reduced the loading time of the page of another 1.5-2 sec by dividing the individual elements in the cache and working on it individually.

      hence the idea to further reduce the cache into partitions even smaller in relation to what is produced by the manager. Now the change of a resource (or its additional information, as in my case of CRC that extend modResource or xpdoSimpleObject) involves only small parts of the cache, maintaining high performance even with a massive editing of content.
      I think it's a good solution, at least for me that I have to load a lot of resources into a single page, and for each of these many other classes related to them.

      This is the difference of loading page time after edit element on manager panel:
      Avarage time page load before (same server test from Amsterdam): 25-30 sec for the first request (lol, don't ask my why, maybe for all the CRC that have to handle and related query)
      Avarage time page load after (same server test from Amsterdam): 1-1,5 sec always


      the only thing I miss now is to call the function runSnippet() with my parameters. I do not understand why it fails
      [ed. note: solidusite last edited this post 12 years, 11 months ago.]
        Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
        • 3749
        • 24,544 Posts
        I can't tell you what the problem is, but why not put the snippet's code in your plugin and save some more time?

          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 41592 ☆ A M B ☆
          • 83 Posts
          I try to do it, but i've encountered in a new problem. my Plugin calls a chunk, processes it and wrote on cache partition, great. But my chunk processed contains other chunks e those chunks are not processed yet. I've half chunk processed sad

          To build the properties of this chunk (my wrapper Chunk) I call a public method in my CRClasses, inside this method I've some Xpdo Call to get and process internal chunks. And those are the pieces of my chunk that not processed (problem still remain therefore I use $xpdo->getChunk or $xpdo->getObject('modChunk') and process it).
          Trying to var_dump my properties array I can see that the properties that should have the internal processed chunk (from my CRC method) is empty! Why? sad

          This is my var_dump of properties that my chunk should process, as you can see, the properties "prezzo" is empty! It should contains my processed internal chunk as a string:(

          (
              [listViewTitle] => 
              [destinationID] => 79
              [destinationName] => Temptation Resort Spa
              [target] => couple
              [listViewDescription] => <p>All-Inclusive Lifestyle Resort eccitante, erotico, divertente... in una parola: unico! In un 'ambiente amichevole e stimolante, aperto tutto l'anno è la destinazione perfetta per fuggire alla realtà, vivere i sogni e le vostre passioni più interiori.</p>
              [listViewImage] => ima9_cancun_resort_singles_vacations_adults_all_inclusive.jpg
              [flagIcon] => mexico_località.png
              [country] => Messico
              [resource_id] => 79
              [logo] => ./log_temptation.png
              [style] => margin-top:35px
              [prezzo] =>  
              [class] => Chiaro
              [h1Class] => resortTitle
          )
          


          The same problem is present if I try to put in my external Chunk a calling to unprocessed internal chunk, like [[$chunkToProcess]]

          Any suggestion? [ed. note: solidusite last edited this post 12 years, 11 months ago.]
            Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
            • 3749
            • 24,544 Posts
            Are you using the chunk's process method?


            $chunk = $modx->getChunk('somechunk');
            $output = $chunk->process();
            


              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 41592 ☆ A M B ☆
              • 83 Posts
              Yes,My wrapper chunk is generated by the same logic of getCache. Maybe I found a solution, i've to try it.

              Parsing a String
              Sometimes you need to parse a string using the MODX parser – this does not use getChunk, but it is related. Using the MODX parser is a bit slower than using a simple str_replace function, but it does let you use complex placeholders (e.g. to include another Chunk) and output filters etc. The trick is to create a temporary Chunk object, then run the process method on it.

              Maybe I've to do this with my internal chunk? Argh today i'm traveling I can't xD
                Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]