[TUTORIAL] Using Caching to Speed Up Your Code
- mjaz
- Joomla! Guru
- Posts: 821
- Joined: Thu Nov 10, 2005 10:08 am
- Contact:
[TUTORIAL] Using Caching to Speed Up Your Code
Hi,
I wrote a very basic quickstart tutorial on caching functions in 1.5. Feel free to edit it, rewrite it, publish it in the wiki, tattoo it on your forehead, or ignore it
EDIT: removed attachment. Read it at http://dev.joomla.org/component/option, ... g_caching/
I wrote a very basic quickstart tutorial on caching functions in 1.5. Feel free to edit it, rewrite it, publish it in the wiki, tattoo it on your forehead, or ignore it
EDIT: removed attachment. Read it at http://dev.joomla.org/component/option, ... g_caching/
Last edited by mjaz on Mon Jan 08, 2007 6:52 pm, edited 1 time in total.
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Hi mjaz,
Excellent work Mathias. This is just the kind of material we need right now. I'll get it edited, formatted and posted on the dev wiki shortly.
In the meantime a big thank you and please feel free to write some more.
Regards,
Chris.
Excellent work Mathias. This is just the kind of material we need right now. I'll get it edited, formatted and posted on the dev wiki shortly.
In the meantime a big thank you and please feel free to write some more.
Regards,
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
- Jinx
- Joomla! Champion
- Posts: 6508
- Joined: Fri Aug 12, 2005 12:47 am
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Keep in mind that the whole caching layer is still in WIP and is slated to undergo a refactoring (it's the last major part of the architecture we still need to deal with). We hope to start on it soonish, probably end of next week.
Good work nevertheless, especialy the profiler stuff is fixed and will not change so this can be documented already.
Good work nevertheless, especialy the profiler stuff is fixed and will not change so this can be documented already.
Last edited by Jinx on Fri Jan 05, 2007 11:57 pm, edited 1 time in total.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5
http://www.joomlatools.com - Joomla extensions that just work
http://www.joomlatools.com - Joomla extensions that just work
- mjaz
- Joomla! Guru
- Posts: 821
- Joined: Thu Nov 10, 2005 10:08 am
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
I needed caching for an extension i'm making. I couldn't find any docs, so I decided to document my progress as I discovered how it works. Didn't know it was still WIP. If the api changes, let us know.
btw Respect to the doc people :-* , I never imagined writing even such a basic tut could be such hard work. I'll see if I can write some more, no promises though.
btw Respect to the doc people :-* , I never imagined writing even such a basic tut could be such hard work. I'll see if I can write some more, no promises though.
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
"What's easy reading is damned hard writing." G. K. Chesterton (if memory serves)mjaz wrote: I never imagined writing even such a basic tut could be such hard work.
@Johan. Thanks for the warning, I'd forgotten about that. I'll post it on the dev wiki anyway, but I'll include a prominent health warning too.
Regards,
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
- Jinx
- Joomla! Champion
- Posts: 6508
- Joined: Fri Aug 12, 2005 12:47 am
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Thanks guys ! Good team work I call this one.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5
http://www.joomlatools.com - Joomla extensions that just work
http://www.joomlatools.com - Joomla extensions that just work
- mjaz
- Joomla! Guru
- Posts: 821
- Joined: Thu Nov 10, 2005 10:08 am
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
After a quick look at the changes in svn, this should be changed in the tutorial:
1. The profiler apparently is not available by default, so all code should have:
2. cleanCache() is now clean():
instead of
3. When getting a reference to the cache object, it will default to 'output', but we need 'callback', so:
4. call() is a wrapper for get(), so we'll use:
The complete code in part 5 of the tut now looks like this:
The other code examples should be changed as well.
I'll keep an eye out for any further changes to the svn.
1. The profiler apparently is not available by default, so all code should have:
Code: Select all
jimport( 'joomla.utilities.profiler' );
Code: Select all
$cache->clean();
Code: Select all
$cache->cleanCache();
Code: Select all
// Get a reference to the global cache object.
$cache = & JFactory::getCache( 'callback' );
Code: Select all
$rows = $cache->get( array( 'TestClass', 'testMethod' ), $table );
The complete code in part 5 of the tut now looks like this:
Code: Select all
<?php
jimport( 'joomla.utilities.profiler' );
class TestClass {
function testMethod( $table ) {
// Get a reference to the global database object.
$db = & JFactory::getDBO();
// Execute the same database query 250 times.
for( $i=0; $i<250; $i++) {
$db->setQuery( "SELECT * FROM #__$table" );
$rows = $db->loadObjectList();
}
return $rows;
}
}
// Determine which database table to query.
$table = JRequest::getVar( 'table', 'content' );
// Get a reference to the global cache object.
$cache = & JFactory::getCache('callback' );
// Run the test without caching.
$profiler = new JProfiler();
$rows = TestClass::testMethod( $table );
echo $profiler->mark( ' without caching' );
// Run the test with caching.
$profiler = new JProfiler();
$rows = $cache->get( array( 'TestClass', 'testMethod' ), $table );
echo $profiler->mark( ' with caching' );
?>
I'll keep an eye out for any further changes to the svn.
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Hi mjaz,
Rather than update the wiki right now I think I'll wait until we can be certain that the refactoring of the cache code has been completed. Last I heard it was still work in progress.
Thanks for the update Mathias.
Regards,
Chris.
Rather than update the wiki right now I think I'll wait until we can be certain that the refactoring of the cache code has been completed. Last I heard it was still work in progress.
Thanks for the update Mathias.
Regards,
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
- Jinx
- Joomla! Champion
- Posts: 6508
- Joined: Fri Aug 12, 2005 12:47 am
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
It still is indeed, while the code is roughly done we still need to implement it and this usualy goes with some refactoring.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5
http://www.joomlatools.com - Joomla extensions that just work
http://www.joomlatools.com - Joomla extensions that just work
- mjaz
- Joomla! Guru
- Posts: 821
- Joined: Thu Nov 10, 2005 10:08 am
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Ok. Maybe you can add backlink to this thread in the wiki.
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Good idea. Done.
Regards,
Chris.
Regards,
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
- markuz
- Joomla! Enthusiast
- Posts: 225
- Joined: Tue Nov 08, 2005 6:43 pm
- Location: the Netherlands
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Jinx,Jinx wrote: It still is indeed, while the code is roughly done we still need to implement it and this usualy goes with some refactoring.
What is the status of the code regarding to caching? I'm exploring the possibilities for my component.
I'm facing several issues like: pathway building problems, registration of 'hits', JToolbarHelper doesn't get called in the backend, etc. etc. Are these issues to be solved, or is it simply not covered by the cache layer?
Thanks in advance,
Mark
Last edited by markuz on Fri Jun 22, 2007 11:06 am, edited 1 time in total.
-
- Joomla! Intern
- Posts: 71
- Joined: Mon Sep 12, 2005 7:54 am
Re: [TUTORIAL] Using Caching to Speed Up Your Code
I'm with Markuz, before I go digging around too much with this, does the article stand correct, or is the cache completely refactored and invalidates this article?
Todd
Todd
- torkil
- Joomla! Guru
- Posts: 726
- Joined: Wed Aug 24, 2005 9:34 am
- Location: Rørvik, Norway
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Same question.
- torkil
- Joomla! Guru
- Posts: 726
- Joined: Wed Aug 24, 2005 9:34 am
- Location: Rørvik, Norway
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
I forgot to say that I got a response to this: The cache code is done.
- markuz
- Joomla! Enthusiast
- Posts: 225
- Joined: Tue Nov 08, 2005 6:43 pm
- Location: the Netherlands
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Thanks Torkil,
Still have the following issues though...
Still have the following issues though...
Markmarkuz wrote: I'm facing several issues like: pathway building problems, registration of 'hits', JToolbarHelper doesn't get called in the backend, etc. etc. Are these issues to be solved, or is it simply not covered by the cache layer?
-
- Joomla! Champion
- Posts: 7018
- Joined: Wed Nov 22, 2006 3:35 pm
- Location: Nebraska
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
The wiki points to this thread - and this thread points to the wiki - as the most current documentation. Following is from the wiki.
Thanks!
Amy
It appears the wiki is up to date, now. Should the wiki warning now be removed?Warning: The Joomla! 1.5 cache API is currently being refactored and you should not rely on the information contained in this tutorial remaining true. Further information may be found in this forum thread.
Thanks!
Amy
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
Wiki warning has been removed.
Thanks for the reminder Amy.
Chris.
Thanks for the reminder Amy.
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
- Kampp
- Joomla! Guru
- Posts: 563
- Joined: Tue Aug 30, 2005 9:18 am
- Location: Denmark
- Contact:
Re: [TUTORIAL] Using Caching to Speed Up Your Code
The wiki link does not work anymore....
http://www.toolmaster.dk - Danish Joomla Services!
- Chris Davenport
- Joomla! Ace
- Posts: 1370
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: [TUTORIAL] Using Caching to Speed Up Your Code
It's been moved to the "new" wiki: http://docs.joomla.org/Using_caching_to ... _your_code
Regards,
Chris.
Regards,
Chris.
Chris Davenport
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/
Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/