Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
datastore cache to XCache - boost your vBulletin Details »»
datastore cache to XCache - boost your vBulletin
Version: 0.8.5, by phpxcache phpxcache is offline
Developer Last Online: Mar 2008 Show Printable Version Email this Page

Category: Board Optimization - Version: 3.6.5 Rating:
Released: 03-02-2007 Last Update: 03-03-2007 Installs: 142
Code Changes Additional Files  
No support by the author.


(note: do not apply this patch on vBulletin 3.7 as it's included already)
This patch allow you to use XCache as a datastore cache in vBulletin. This is definitely your choice if you have installed and enabled XCache on you server already.

Take care that this is a beta version and was not heavily tested. And i'm not familiar with vBulletin source code as i just started reading it today, but i don't have any difficulty reading it thanks to my years of php skill

Take aware that some vB plugin is not compatible with vB_datastore_*, not just vB_datastore_XCache. So, in case you find vB_datastore_XCache won't work, you'd better try datastore to file or memcache. If one of the others works but not vB_datastore_XCache, do report it to me so i can fix it.

Pre-requirement
Install the modification
for those of you who can't run "patch", u may patch the file manually
  • download Attachment 61372 (class_datastore_xcache.php)
  • save the file as vBulletin.3.6/upload/includes/class_datastore_xcache.php
  • open vBulletin.3.6/upload/includes/class_datastore.php in your favor editor
  • add a line in class_datastore.php (see below)
  • update upload/includes/config.php to enable it (see below)

example class_datastore.php after modification:
PHP Code:
        }
        return 
true;
    }
}

// add class_datastore_xcache, enable it in config.php
require_once(DIR '/includes/class_datastore_xcache.php');

/*======================================================================*\
|| ####################################################################
|| # Downloaded: 12:33, Fri Mar 2nd 2007
|| # CVS: $RCSfile$ - $Revision: 15474 $
|| ####################################################################
\*======================================================================*/ 
example config.php after modification:
PHP Code:

    
// vB_Datastore_Filecache  - for using a cache file
// $config['Datastore']['class'] = 'vB_Datastore_Filecache';
$config['Datastore']['class'] = 'vB_Datastore_XCache';
    
// vB_Datastore_Memcached - for using a Memcache server
    // It is also necessary to specify the hostname or IP address and the port the server is listening on 
Trouble Shooting
q. i have multiple vBulletin instance installed, the seems to mix data after install this plugin
a. this applies to apc too because, if you wanna fix it, try
open class_core.php, look for:
$this->prefix =& $this->registry->config['Datastore']['prefix'];
and modify to:
$this->prefix = $this->registry->config['Datastore']['prefix'] . $_SERVER['SERVER_NAME']; // or HTTP_HOST

q. Warning: unserialize() expects parameter 1 to be string, array given in $a.php on line $b
a. upgrade your plugin/hack that $a.php belongs to, e.g. vbjournal/vbgallery etc. OR open $a.php and locate at line $b, remove unserialize call, e.g.:
replace $var = unserialize($this->data);
with $var = $this->data;
be careful do not remove the whole line, just the unseralize( and )

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 03-03-2007, 11:31 AM
lendy lendy is offline
 
Join Date: Mar 2004
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

edit file includes/class_datastore.php
at th end (above ?>)
add nether php code
PHP Code:

/**
* Class for fetching and initializing the vBulletin datastore from XCache
*
* @package    vBulletin
* @version    $Revision: $
* @date        $Date: $
*/
class vB_Datastore_XCache 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 XCache
    *
    * @param    array    Array of items to fetch from the datastore
    *
    * @return    void
    */
    
function fetch($itemarray)
    {
        if (!
function_exists('xcache_get'))
        {
            
trigger_error('XCache not installed'E_USER_ERROR);
        }

        if (!
ini_get('xcache.var_size'))
        {
            
trigger_error('XCache variable data cache is not enabled, please set xcache.var_size in php.ini'E_USER_ERROR);
        }

        
$db =& $this->dbobject;

        
$itemlist = array();

        foreach (
$this->defaultitems AS $item)
        {
            
$this->do_fetch($item$itemlist);
        }

        if (
is_array($itemarray))
        {
            foreach (
$itemarray AS $item)
            {
                
$this->do_fetch($item$itemlist);
            }
        }

        
$this->store_result true;

        
// some of the items we are looking for were not found, lets get them in one go
        
if (!empty($itemlist))
        {
            
$this->do_db_fetch(implode(','$itemlist));
        }

        
$this->check_options();

        
// set the version number variable
        
$this->registry->versionnumber =& $this->registry->options['templateversion'];
    }

    
/**
    * 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, &$itemlist)
    {
        
$ptitle $this->prefix $title;

        if ((
$data xcache_get($ptitle)) === null)
        { 
// appears its not there, lets grab the data, and put it in
            
$itemlist[] = "'" $this->dbobject->escape_string($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)
    {
        if (
$this->store_result === true)
        {
            
$this->build($title$data);
        }
        
parent::register($title$data);
    }

    
/**
    * 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;

        
xcache_unset($ptitle);
        
xcache_set($ptitle$data);
    }

}

// ############################################################################# 
and edit includes/config.php
add or edit
$config['Datastore']['class'] = 'vB_Datastore_XCache';

precondition:
you must install xcache,and set xcache.var_size not 0,same as xcache.size in php.ini
Reply With Quote
  #13  
Old 03-03-2007, 12:06 PM
Mudvayne's Avatar
Mudvayne Mudvayne is offline
 
Join Date: Dec 2005
Location: /dev/null/
Posts: 393
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by jedisct1 View Post
Reserved
Why & what for? :S LOL
Reply With Quote
  #14  
Old 03-03-2007, 12:45 PM
Deimos Deimos is offline
 
Join Date: Oct 2002
Posts: 529
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I assume we put the "vB_Datastore_XCache" File in the includes/datastore directory?
Reply With Quote
  #15  
Old 03-03-2007, 01:28 PM
vBB-vietnam vBB-vietnam is offline
 
Join Date: Apr 2006
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My server OS window 2003 . .Apache v2.0.59 , PHP 4.4.5
Can i use it .
sorry for my bad english
Reply With Quote
  #16  
Old 03-03-2007, 01:39 PM
MikeWarner's Avatar
MikeWarner MikeWarner is offline
 
Join Date: Nov 2001
Location: UK
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by lendy View Post
precondition:
you must install xcache,and set xcache.var_size not 0,same as xcache.size in php.ini
Eh? My var size is 0. You saying I have to set this to the same as what the xcache.size is? (100mb). Really? That much?

More info on this woul be good. I just tried to install this and got errors. I didn;t change the var size from 0, plus I assumed the location of the attached php file.

Please can more details be added to this hack as I would like to use it.

Thanks.
Reply With Quote
  #17  
Old 03-03-2007, 01:50 PM
phpxcache phpxcache is offline
 
Join Date: Feb 2007
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i have updated the topic again.
setting "xcache.var_size not 0" is same as "xcache.size"
xcache.var_size = 10M or so is fine, just resize it for to fit your needs.

you gotta copy the content of the whole php file i attached into class_datastore.php, there's no new file is created or added
Reply With Quote
  #18  
Old 03-03-2007, 03:23 PM
Zia's Avatar
Zia Zia is offline
 
Join Date: Dec 2005
Location: golpo.net
Posts: 931
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vBB-vietnam View Post
My server OS window 2003 . .Apache v2.0.59 , PHP 4.4.5
Can i use it .
sorry for my bad english
I gez u can ..i gez
to use this(this thread) mods..u must have Xcache install in ur box
Quote:
Download Win32AutoBuilds at here/XCache-VERSION-php-x.y.x-Win32-rREV.zip. This is an official SvnSnapShots autobuild, but NOT release version.
Check InstallingAsPhpExtension for instructions. (the doc is not updated for win32 yet)
It can be very hard to compile for Win32. If you're gonna do it yourself, Cygwin is required, and check the simple README to accomplish the complex job.

Disassembler is avaiable in source but missing one file due to license problem, so not built into win32 binary package. btw, disassembler isn't designed to work with commercal encoders/encrypters.
http://trac.lighttpd.net/xcache/wiki/Win32AutoBuilds

(The Author phpxcache can explain u better)
After u got xcache installed on ur Box..U can use this mods for datastore cache.
Reply With Quote
  #19  
Old 03-03-2007, 03:31 PM
Zia's Avatar
Zia Zia is offline
 
Join Date: Dec 2005
Location: golpo.net
Posts: 931
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MikeWarner View Post
Eh? My var size is 0. You saying I have to set this to the same as what the xcache.size is? (100mb). Really? That much?
More info on this woul be good. I just tried to install this and got errors. I didn;t change the var size from 0, plus I assumed the location of the attached php file.
Please can more details be added to this hack as I would like to use it.
Thanks.
Thanks for ur interest. I will try to provide u some info..see it it helps u a bit..

See bellow xcache.ini of our box

Quote:
; select low level shm/allocator scheme implemenation
xcache.shm_scheme = "mmap"
xcache.size = 64M
xcache.count = 4
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0

; same as aboves but for variable cache
xcache.var_size = 64M
xcache.var_count = 4
xcache.var_slots = 8K
; default ttl
xcache.var_ttl = 0
xcache.var_maxttl = 0
;xcache.var garbage collect interval set to 6 hour.
xcache.var_gc_interval = 21600
Pls follow the red color text
xcache.size & xcache.var_size both set to 64Mb .
And ur using 100 Mb for xcache.size . did u really need that much memory ? we set 64MB.33Mb used and still 31MB is free out of 64Mb. when vbplaza on it just consume 3~4Mb more + few more php cached.

check ur xcache admin cp & if needed reduce allocated memory OR if u got enugh memory at ur box/server ..then u can use 100MB+100 Mb.

Point is that u have to put same MB of memory at xcache.size & xcache.var_size

php file in the attachmnet
Quote:
you gotta copy the content of the whole php file i attached into class_datastore.php, there's no new file is created or added
Reply With Quote
  #20  
Old 03-03-2007, 03:38 PM
MikeWarner's Avatar
MikeWarner MikeWarner is offline
 
Join Date: Nov 2001
Location: UK
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No - I need 100mb. I have tried to reduce it, but was getting ooms using 90mb. I'll give it a try later. Thanks.
Reply With Quote
  #21  
Old 03-03-2007, 03:54 PM
MikeWarner's Avatar
MikeWarner MikeWarner is offline
 
Join Date: Nov 2001
Location: UK
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by phpxcache View Post
you gotta copy the content of the whole php file i attached into class_datastore.php, there's no new file is created or added
So I need to replace the class_datastore.php file with the included file (renamed)?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05006 seconds
  • Memory Usage 2,366KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete