Path

ez projects / self_var_cache


SELF Var Cache

UNIX name Owner Status Version Compatible with
self_var_cache Piotr Karaś planning 0.2 alpha 4.0.0

This extension is meant to provide additional caching layer/method
dedicated to variables.

There are multiple problems with accessing and managing variables that
have been placed within view cache and template cache, especially
when they have to be reused and different expiry times are set for
cache blocks.
This extension enables to cache variable collections, so that the
variables can be easily placed and available in non-cached template
areas, for example directly in the pagelayout, but without being
fetched over and over again.
Please let me know if the extension requires additional explanation or
tutorial.
NOTE: This is purely experimental! Even though this is a removable layer,
don't use it in a production environment just quite yet ;)
MORE:
EXAMPLE:
{def $keys=array( $module_result.node_id ) $expiry=3600
$collection='main_vars'}
{if not( selfvarcache_getcollection( $collection, $keys, $expiry )
)}
{selfvarcache_setcollection( $collection, $keys, $expiry, hash(
'current_node_id', $module_result.node_id,
'current_time', currentdate(),
'current_node', fetch( 'content', 'node', hash( 'node_id', $module_result.node_id )
),
) )}
{/if}
Suggested model:
{if not( selfvarcache_getcollection( $collection, $keys, $expiry )
)}
{* Here you put all your expensive calculations and operations *}
{* that will be cached as variables in the next step *}
{selfvarcache_setcollection( $collection, $keys, $expiry, hash(
'variable_name_1', 'variable_value_1',
'variable_name_2', 'variable_value_2',
) )}
{/if}
Additional inspection operator selfvarcache_fetchcollection for compuond
vars:
{def $keys=array( $module_result.node_id ) $expiry=3600
$collection='main_vars'}
{if not( selfvarcache_getcollection( $collection, $keys, $expiry )
)}
{selfvarcache_setcollection( $collection, $keys, $expiry, hash(
'current_node_id', $module_result.node_id,
'current_time', currentdate(),
'current_node', selfvarcache_fetchcollection(
fetch( 'content', 'node', hash( 'node_id', $module_result.node_id ) ), 2

),
) )}
{/if}

 

Screenshot

This project has no reviews yet. Be the first one to review it!

No forum messages yet.