DooPHP IRC channel


add "/" and parameters in caches' id

Discussion about new desired features.

add "/" and parameters in caches' id

Postby lucian » Mon Sep 21, 2009 10:04 am

1)when using templates, I would like to add parameters in cache ids, for example:

<!-- loop students -->

<!-- cache("students/{{students' value.@id}}") -->
{{students' value.@name}}
<!-- endcache -->
<!-- endloop -->

is it possible to add this feature in?

2) is it possible to add "/" in caches' id?
like :

<!-- cache("kids/09/06/") -->
<!-- endcache -->

it seems that it doesn't work at the moment...
lucian
 
Posts: 11
Joined: Sat Sep 19, 2009 8:41 am

Re: add "/" and parameters in caches' id

Postby leng » Mon Sep 21, 2009 12:08 pm

no, you can't use / in the cache id for frontend cache currently.

This will not work too with the current code.
Code: Select all
<!-- cache("students/{{students' value.@id}}") -->


However, you can write your functions to use Doo::cache('front') in template_tags.php

Code: Select all
function startCache($id, $duration, $additional=''){
     if (!Doo::cache('front')->getPart($additional . $id, $duration))
          Doo::cache('front')->start('mydata');
}

function endCache($id, $duration, $additional=''){
     if (!Doo::cache('front')->getPart($additional . $id, $duration))
           Doo::cache('front')->end();
}



Template:
Code: Select all
<!-- loop students -->

{{startCache(students' value.@id, 3600, 'students')}}
{{students' value.@name}}
{{endCache(students' value.@id, 3600, 'students')}}
<!-- endloop -->


You can have the functions to convert the / to something else like '-' or '_'
Just Doo IT!
leng
 
Posts: 1482
Joined: Thu Jul 16, 2009 11:33 pm


Return to Features Request

Who is online

Users browsing this forum: No registered users and 1 guest

cron