HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Comcode Caching and Randomness!

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#18913 (In Topic #4394)
Avatar

Well-settled

Hellooo!

Just had an interesting problem crop up on my 2.6 install. When running the srand function with the comcode page cache on, it doesn't pick a random value form the lsit given, merely the last one you got.

Is there any way at all to turn off comcode page caching for specific pages?

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#18914
Avatar

Hopefully I'm correct in assuming this is what you meant ;)

'srnad function' -> SET_RAND symbol
'lsit' -> list

The answer is no I'm afraid, but I'll look into the problem.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#18915
Avatar

Well-settled

I think I probably used it in a unique way to randomly include a page (which in this case featured a short intro about each game the site covers).

Herein lieth my comcode, which works quite well so long as comcode caching is off ;) :

Code

[include]{$SET_RAND,featured_eu,featured_tftd,featured_int,featured_apoc,featured_enf,featured_am,featured_as,featured_al,featured_s2,featured_s3}[/include]

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#18916
Avatar

Ah, I see. Yeah, unfortunately that's not going to work because the contents of that tag has to get computed even for the page's Tempcode to be made (it is the Tempcode which gets cached).

Cacheing of comcode pages is stored in sources/site.php (load_comcode_page)… you could add some code there to make your own exceptions.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#18918
Avatar

Well-settled

Cheers Chris, I shall take a look - it's not like it even slows it down that much with the other caches on ;)

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#18919
Avatar

What was I thinking? You don't need code hacks to do this. All you need to do is to make a quick mini-block:

Code

<?php

$comcode=<<<END
[include]{$SET_RAND,featured_eu,featured_tftd,featured_int,featured_apoc,featured_enf,featured_am,featured_as,featured_al,featured_s2,featured_s3}[/include]
END;
$tpl=comcode_to_tempcode($comcode,NULL,true);
$tpl->evaluate_echo();

?>

And then include that mini-block in your greater page using the 'block' tag. As mini-blocks aren't cached, you've created yourself a little cacheless island :).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#18924

Non-joined user

Woohoo!

Cheers Chris :)

One thing that still confuses me though is why the main_forum_news block seems to cache by default. Obviously just commenting out the cache code lines in the block will stop it, but it struck me as bizarre because your new news posted on the forums won't show up for a while on the site ;)
Back to the top
 
Posted
Rating:
#18925
Avatar

It's a compromise - fewer queries, but with a slight lag.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#18941
Avatar

Well-settled

Just out of curiosity, is the slight lag set by the following line of code, and if so is that in minutes? So if the cached page is more than 60 minutes old then grab fresh data?

Code

$info['ttl']=60;

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#18942
Avatar

Correct :).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#18943
Avatar

Well-settled

Neato, I shall change it to ten minutes so my news poster's don't get too confused ;)

 The Last Outpost - Entertainment news, reviews, previews & interviews. No holds barred - big boys' language in use!

Back to the top
 
Posted
Rating:
#18944

Non-joined user

Oooh, just bumped into a problem with my mini block - did evrything right but it doesn;t like that SET RAND bit:

Code

Parse error: parse error, unexpected ',', expecting '}'
in /home/username/public_html/installdir/sources_custom/blocks/my_block.php on line 4

Also, when I did my last reply in this topic, the New Post button disapperaed after posting.I've had to logout to add a new reply… is this some sort of flood control or is it to stop a user posting twice in a row? ;)
Back to the top
 
Posted
Rating:
#18945
Avatar

In PHP, $ in the "<<<END … END;" and double-quoted strings will try and map to a PHP variable. I should have said…

Code

$comcode=<<<END
[include]{\$SET_RAND,featured_eu,featured_tftd,featured_int,featured_apoc,featured_enf,featured_am,featured_as,featured_al,featured_s2,featured_s3}[/include]
END;

to stop a user posting twice in a row?

It's this. It's an OCF option… the double post permission.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: