vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Board Optimization - datastore cache to XCache - boost your vBulletin (https://vborg.vbsupport.ru/showthread.php?t=141005)

lendy 03-03-2007 11:31 AM

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

Mudvayne 03-03-2007 12:06 PM

Quote:

Originally Posted by jedisct1 (Post 1194687)
Reserved

Why & what for? :S LOL

Deimos 03-03-2007 12:45 PM

I assume we put the "vB_Datastore_XCache" File in the includes/datastore directory?

vBB-vietnam 03-03-2007 01:28 PM

My server OS window 2003 . .Apache v2.0.59 , PHP 4.4.5
Can i use it .
sorry for my bad english

MikeWarner 03-03-2007 01:39 PM

Quote:

Originally Posted by lendy (Post 1194773)
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.

phpxcache 03-03-2007 01:50 PM

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

Zia 03-03-2007 03:23 PM

Quote:

Originally Posted by vBB-vietnam (Post 1194831)
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.

Zia 03-03-2007 03:31 PM

Quote:

Originally Posted by MikeWarner (Post 1194838)
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 . :confused: did u really need that much memory ?:eek: 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

MikeWarner 03-03-2007 03:38 PM

No - I need 100mb. I have tried to reduce it, but was getting ooms using 90mb. I'll give it a try later. Thanks.

MikeWarner 03-03-2007 03:54 PM

Quote:

Originally Posted by phpxcache (Post 1194847)
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)?


All times are GMT. The time now is 02:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01326 seconds
  • Memory Usage 1,786KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete