The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Custom items in VB datastore
Without getting into the whys and wherefores I have coded a page that displays a lot of data that is pulled from the database, this works perfectly and all is good.
However, there is no need for this data to be re-queried on every page view so the obvious solution is the cache the data, when needed pull it from the cache and periodically purge and refresh the cache. It seems like a good idea to reuse as much of the existing datastore system that already exists in vBulletin. I can store into the cache using: Code:
build_datastore('mycustomdata', serialize($mycustomdata), 1); I did consider putting it into something like $vbulletin->options but this would mean that the data would be loaded in on all pages which is unnecessary and would waste resources. --------------- Added [DATE]1254311069[/DATE] at [TIME]1254311069[/TIME] --------------- Problem Solved To do this you need to give your custom datastore a name, and then pass this name to the $specialtemplates array. Code speaks a thousand words, so... Code:
<?php error_reporting(E_ALL & ~E_NOTICE); define('NO_REGISTER_GLOBALS', 1); define('THIS_SCRIPT', 'testvbcache'); $phrasegroups = array(); $specialtemplates = array('mycustomdatastoretemplate'); $globaltemplates = array(); $actiontemplates = array(); require_once('./global.php'); if (isset($vbulletin->mycustomdatastoretemplate)) { //The custom datastore item is available so just echo out the current //datastore value. echo 'RETRIEVED: ' . $vbulletin->mycustomdatastoretemplate['arraykey']; } else { //The custom datastore item is not available so create it and add to //the datastore $mycustomdata = array(); $mycustomdata['arraykey'] = 'This is the value of array key'; build_datastore('mycustomdatastoretemplate', serialize($mycustomdata), 1); echo 'ADDED: ' . $mycustomdata['arraykey']; } ?> The first time this script is run it will output: Code:
ADDED: This is the value of array key Code:
RETRIEVED: This is the value of array key |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|