Back to vBulletin 4.x Add-ons

Datastore cache to WinCache - boost your vBulletin
Mod Version: 1.01, by hydn

vB Version: 4.0.2 Rating: (2 votes - 5.00 average) Installs: 14
Released: 30 Mar 2010 Last Update: Never Downloads: 0
Not Supported Code Changes  

This allows you to use https://www.iis.net/expand/WinCacheForPhp as a datastore cache in vBulletin. This also assumes that you have already installed Wincache version 1.1 or later. This is definitely your choice if you have already installed and enabled WinCache on your windows server. Use at your own risk!

(See screenshot of stats below after 30mins up-time)

Prerequisites
  • a working php installation
  • a working vBulletin 4.0.2 installation
  • a working WinCache 1.1 or Better.
Install the modification
  1. Add the following code to the end of class_datastore.php just above "?>"
Code:
// #############################################################################
// WINCACHE
/**
* Class for fetching and initializing the vBulletin datastore from WINCACHE
*/
class vB_Datastore_WINCACHE extends vB_Datastore
{
                /**
                * Indicates if the result of a call to the register function should store the value in memory
                *
                * @var  boolean
                */
                var $store_result = false;
                /**
                * Fetches the contents of the datastore from WINCACHE
                *
                * @param           array      Array of items to fetch from the datastore
                *
                * @return           void
                */
                function fetch($items)
                {
                                if (!function_exists('wincache_ucache_get'))
                                {
                                                trigger_error('WINCACHE not installed', E_USER_ERROR);
                                }
                                if (!sizeof($items = $this->prepare_itemarray($items)))
                                {
                                                return;
                                }
                                $unfetched_items = array();
                                foreach ($items AS $item)
                                {
                                                $this->do_fetch($item, $unfetched_items);
                                }
                                $this->store_result = true;
                                // some of the items we are looking for were not found, lets get them in one go
                                if (!empty($unfetched_items))
                                {
                                                if (!($result = $this->do_db_fetch($this->prepare_itemlist($unfetched_items))))
                                                {
                                                                return false;
                                                }
                                }
                                $this->check_options();
                                return true;
                }
                /**
                * Fetches the data from shared memory and detects errors
                *
                * @param           string     title of the datastore item
                * @param           array      A reference to an array of items that failed and need to fetched from the database
                *
                * @return           boolean
                */
                function do_fetch($title, &$unfetched_items)
                {
                                $ptitle = $this->prefix . $title;
                                if (($data = wincache_ucache_get($ptitle)) === false)
                                { // appears its not there, lets grab the data, lock the shared memory and put it in
                                                $unfetched_items[] = $title;
                                                return false;
                                }
                                $this->register($title, $data);
                                return true;
                }
                /**
                * Sorts the data returned from the cache and places it into appropriate places
                *
                * @param           string     The name of the data item to be processed
                * @param           mixed   The data associated with the title
                *
                * @return           void
                */
                function register($title, $data, $unserialize_detect = 2)
                {
                                if ($this->store_result === true)
                                {
                                                $this->build($title, $data);
                                }
                                parent::register($title, $data, $unserialize_detect);
                }
                /**
                * Updates the appropriate cache file
                *
                * @param           string     title of the datastore item
                * @param           mixed   The data associated with the title
                *
                * @return           void
                */
                function build($title, $data)
                {
                                $ptitle = $this->prefix . $title;
                                wincache_ucache_delete($ptitle);
                                wincache_ucache_set($ptitle, $data);
                }
}
2. Set your config.php to use wincache for datastore:

Code:
$config['Datastore']['class'] = 'vB_Datastore_WINCACHE';
Done!

Check the "User and Session Cache" section of your wincache.php (screenshot) in your browser to see stats!

Special thanks to the guys at Microsoft for their help! Official IIS support at https://forums.iis.net

Enjoy!

Download

No files for download.

Screenshots

Click image for larger version
Name:	wincache_datastore_stats.jpg
Views:	534
Size:	199.8 KB
ID:	115007  

Similar Mods

Board Optimization Datastore cache to WinCache - boost your vBulletin vBulletin 3.8 Add-ons
Board Optimization datastore cache to XCache - boost your vBulletin vBulletin 3.6 Add-ons

vblts.ru supports vBulletin®, 2022-2024