Jump to content

User talk:Locke Cole/Rand/Rand.php

Add topic
From Meta, a Wikimedia project coordination wiki
Latest comment: 18 years ago by Locke Cole in topic Pretty basic

Pretty basic[edit]

Only "problem" I'm aware of is that in order for the number to change, you have to purge (action=purge) pages that use it. I assume editing the page would also trigger a new value too. Of course, if it generated a new value each time, pages would never get cached, and that'd be bad. Hence why I put problem in quotes above. :P —Locke Coletc 05:37, 6 April 2006 (UTC)Reply

Okay, $parser->disableCache(); fixed the cache issue. I don't know enough about MediaWiki yet to say for certain though, but I suspect disabling the cache like this on a high traffic site (like en) is probably a bad idea. —Locke Coletc 06:19, 6 April 2006 (UTC)Reply
I know nothing about the Wiki software, but there's that "random file" feature, maybe you can base what you want on the same idea? Min and max are not strictly necessary, expr: can scale any interval (e.g. 0..1) to a desired interval (e.g. min + (max - min) * [0..1]). -- Omniplex (w:t) 14:52, 6 April 2006 (UTC)Reply
PHPs mt_rand() (and regular rand()) returns a regular integer (so no floating point value like some languages return). If we're referring to the cacheing issue, the problem isn't how the random number is generated, just that the software takes great pains to keep from regenerating the page on the fly. =) Rather than disable the cache altogether, I think a better approach would be to say "regenerate this page every minute" or something (IOW: set an "expiration" for the cached page).
And like you, my knowledge of the software is limited, just picking it up as I go. ;) —Locke Coletc 21:41, 6 April 2006 (UTC)Reply