Dynamic Pages module: Avoiding core SQL queries in exchange for REDIS cache

Hi guys, I’ve been using Drupal for about a year, and now I’m trying to start working with hooks to do some cool stuff also to making an increase in our Drupal’s performance .

I’m trying to create a dynamic pages module, which is intended to grab selected content types configured in a backend config form.

I managed to create a new “dynamic_page” content type, which holds the configuration of the content i need to show using some custom tables and the following fields:

Custom node type DYNAMIC_PAGE fields:
– Page ID
– Page title
– max nodes count

Custom tables i’m using:

– Sections: this is a heading, content pane, footer, etc.
— Section ID
— Section name

– Page_section: this is the relation between the dynamic page node, and the section i want in that page.
— Page ID = The page im building
— Section ID = identifier
— Position = order in which need to appear on the page
— NodeID = The Drupal’s node i want to show in the page

Now, sections can appear several times in the same page, for example, i coud add 2 times a content pane made of different content types like: a heading, an image gallery content pane, an article content pane, then a footer. This page structure would look something like this:

. . . . . . . . .

So, to get this working, i simply hooked the node view and added some logic to build the page:

function dynamic_pages_node_view($node, $view_mode, $langcode) {
  switch ($node->type){
    case 'dp_heading':
         . . . . . did some logic here
    case 'dp_carousel':
         . . . . . did some other logic here

  return $node;

Everything goes fine here now i want to cache all this. I mean, some of this pages have a huge amount of visitors, and i don’t want to build the page every time a user asks for it.

In other words, i don’t want Drupal to query the DB looking for the dynamic_page node (and building all the stuff), I just want it to be loaded in REDIS (this and teh entire page) and be delivered to the user directly.

I’ve found this REDIS official project: https://www.drupal.org/project/redis, but it doesn’t solve my problem.

I have also configured the website homepage to be one of this dynamic pages, and couldn’t find a way to use REDIS cache instead of having Drupal loading the dynamic page node form the database.

How can i do this? does anyone knows? Any help will be much appreciated

Thanks in advance!

Drupal version: 

Source: https://www.drupal.org/taxonomy/term/4/feed