|
Saturday 22 November 2008 8:44:10 am
Comment50398
It's never easy and you have to calculate all the variables. In this case especially:
- How often do you <b>have to</b> shuffle? Does it have to be real-time shuffling and why?
- How many users do you expect to walk that path per hour? - Would the operation that you need be possible/easy/efficient with dedicated direct database fetches? Or will you have to rely on eZ API (which in most cases has much overhead because it has to serve all the abstractions). So, in case where you could create an custom operator/fetch that is lightweight and doesn't require caching, you could simply feed it to the JavaScript for dynamic injection. Then it goes 100% live, no delays. If that's not possible, then you may need to use a cache-block for this JavaScript injecting code. For example: you need to create a list of 3 view lines with image path and stuff like that - definitely 20-50 queries at least. So you use set-block function to generate that target HTML code into a variable, and make an injection again, but you put it all in a cache-block with expiry time for example 10 minutes. This means a larger operation every 10 minutes, but otherwise very fast thing. The generating the code could involve shuffling, so you will end up with shuffling every 10 minutes. If that's not satisfactory, why not create pseudo shuffling. You generate 3 or 5 different set-blocks, each with different, random inventory. You then instruct you JS to randomly inject one of those 5. This means one expensive operation, but 5 resulting combinations - enough to make users believe it's real-time shuffling, so you can place a cache-block expiry of a day for that. A schema: <b>node view template:</b> ...
<div id="awaiting_content">Data is being loaded...</div>
...
<b>pagelayout:</b>
...
{$module_result.content}
...
{cache-block expiry=86412}
{set-block variable=$shuffle_1}...operations...{/set-block}
{set-block variable=$shuffle_2}...operations...{/set-block}
{set-block variable=$shuffle_3}...operations...{/set-block}
{set-block variable=$shuffle_4}...operations...{/set-block}
{set-block variable=$shuffle_5}...operations...{/set-block}
<script type="text/javascript" language="javascript">
//<![CDATA[
// some JS random function to pick var $shuffle 1-5
document.getElementById('awaiting_content').innerHTML = '{$shuffle_2}';
//]]>
</script>
{/cache-block}
This is just one possibility. More to discover ;)
--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu
|