The best way to cache Presenter->link()?

Notice: This thread is very old.
David Šolc
Member | 5
+
+1
-

I am rendering a lot of data in overview template. There was no point to paginate the result till now, so I was rendering all of data (±1000 rows) in a table. It was ok until I added some links (4) to each row.

Suddenly response time was much longer, so I profiled the request and here is the result.

http://postimg.org/image/90n3qd39f

10.4+8.9+5.7+4.9+4.7 = 34.6% of time is taking link() method

Here is a result without links.

http://postimg.org/…e/cybdudfnf/

So, I was wondering, what is the best way to cache links?

Thank you for any hints.

Oli
Member | 1215
+
0
-

I think problem is in your router. I would say you use database without cache in router, dont you? Use cache for your database query eg. id => slug.

David Grudl
Nette Core | 8227
+
+7
-
{var $magic = 9999}
{capture $link}{link Product:detail $magic}{/capture}

{foreach $products as $product}
	<a href="{$link|replace:$magic:$product->id}">...</a>
{/foreach}