MyBB Community Forums

Full Version: Cache Usage / Query Updating
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Recently i been getting more into mybb dev and i'm learning and reading by what other plugins do. I found a plugin that was a add spider plugin not the typical ones this one just inserted queries using an array and is nothing but queries.

I have seen others say in other threads with other issues one being this: http://community.mybb.com/thread-156406-...pid1087748 that the cache should be updated my question is if we code plugins that simply insert queries, should we also be updating the cache to?

What's actually better and how can i tell if it's really working to as far as cache updating?

Current:
    global $db, $cache, $mybb;
    $db->insert_query('banfilters', array('filter' => "*@0-mail.com", 'lastuse' => "0", 'type' => "3", 'dateline' => TIME_NOW));
    $cache->update_bannedemails();

Old:
    global $db;
    $db->insert_query('banfilters', array('filter' => "*@0-mail.com", 'lastuse' => "0", 'type' => "3", 'dateline' => TIME_NOW));

As for cache updating if it is the best practice so to say, then how come more authors simply do not do it?

< Confused.
If the item can be cached (or is cached in the core such as banned emails), the cache should be updated if the backing data is changed.
Creating your own caches for plugins depends on what your plugin does. Cache's absolutely have to be updated if you add columns to the mybb_usergroups table, mybb_forumpermissions table, mybb_forums table. They also need to be done if you are adding rows to tables or data in the database will be inconsistent with what the file says. Without doing that, things may not work as expected because the way the core works is that it prefers to use caches to save queries.

Caches are used when something is not often changed. If it is something that changes frequently, such as the number of posts a thread has, you don't want to use a cache to handle it and it becomes better to use the database.

Does this answer your question?
Both answers summed it up and that's really what i thought to be honest. I was curious about this becuase i dont see alot of people updating and then i realized that pretty much importing things like lets say bots or ban filters have 0 effect until cache is purged, i just needed clarification on that and now i got it.

Thanks to both of you Smile