R
ragtek
Guest
Because XenForo uses Zend Cache, you can use the nice Caching feature also for your admins.
The coders, who uses vB4 and know how nice the cache is, don't need to miss it in XenForo.
I love the cache, because it uses a timeout AND you can have Tags/Events on which tyou can delte the Cache Entries.
For examle:
If you want to show the 10 newest users/threads/posts/whatever on your indexpage, you have huge queries, which run on every index view.
So what can we do, to save the queries?
We can cache the result.
Now if you use the cache you would use:
which would cache the elements for the general lifetime you set up in your config.php
BUT why renew the cache element, if the cache content didn't change?
For this, you can use the Cache Tags (for former vB Add-on Coders => cache events
)
Now we saved the newest threads, and defined 2 tags for this => 'newthread_created' & 'thread_deleted'
That's important, because i want the box "up2date" so i have to "empty the cacheelements" when somebody creates,edits or deletes a thread.
To make this, we have now to empty the defined tags after creating a thread.
That's a "article" about caching, so i don't want to explain here, how to expant the thread datawriter to make this
This is just a quick example, but i hope you enjoy and use it
(Sorry for my bad english, i hope you understand it^^ )
The coders, who uses vB4 and know how nice the cache is, don't need to miss it in XenForo.
I love the cache, because it uses a timeout AND you can have Tags/Events on which tyou can delte the Cache Entries.
For examle:
If you want to show the 10 newest users/threads/posts/whatever on your indexpage, you have huge queries, which run on every index view.
So what can we do, to save the queries?
We can cache the result.
Now if you use the cache you would use:
PHP:
$cache = XenForo_Application::get('cache');
$data = array('foo','bar'. 'tap'); // my results;)
$cache->save($data,
'myId');
BUT why renew the cache element, if the cache content didn't change?
For this, you can use the Cache Tags (for former vB Add-on Coders => cache events

PHP:
$data = array('foo','bar'. 'tap');
$cache->save($data,
'meineragtekid',
array('newthread_created', 'thread_deleted')
);
Now we saved the newest threads, and defined 2 tags for this => 'newthread_created' & 'thread_deleted'
That's important, because i want the box "up2date" so i have to "empty the cacheelements" when somebody creates,edits or deletes a thread.
To make this, we have now to empty the defined tags after creating a thread.
- $cache->clean(
- Zend_Cache::CLEANING_MODE_MATCHING_TAG,
- array('newthread_created')
- );
That's a "article" about caching, so i don't want to explain here, how to expant the thread datawriter to make this

This is just a quick example, but i hope you enjoy and use it

(Sorry for my bad english, i hope you understand it^^ )