vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Cache System Explanation (datastore) (https://vborg.vbsupport.ru/showthread.php?t=110628)

dwh 09-28-2007 02:23 PM

This was a great article and it explained the concept very well. I do have a minor quibble in your example. Rather than name= dog, value=dog, it might help people understand better if the var name and var value were different, e.g. name=dog, value=terrier.

Something I'd add to the discussion is that cron and serialize go hand in hand. The best place to use serialize is when accessing data frequently, therefore using vb's cached datastore w/o adding a query...but the updating of data is relatively infrequent. A classic way to update that data periodically is cron.
https://vborg.vbsupport.ru/showthrea...highlight=cron

vertigo jones 11-09-2007 06:34 PM

I really hope they add a hook that will allow us to add to $specialtemplates before it's actually used. It's kind of a bummer to have to hack up a file over something so simple.

Not to suggest that adding the hook is simple. I think there's some initialization for the hook system in the datastore, or something along those lines. It's just a pain and it would be cool if they stumble across some fix in the future.

Logikos 11-09-2007 07:53 PM

Quote:

Originally Posted by vertigo jones (Post 1379217)
I really hope they add a hook that will allow us to add to $specialtemplates before it's actually used. It's kind of a bummer to have to hack up a file over something so simple.

Not to suggest that adding the hook is simple. I think there's some initialization for the hook system in the datastore, or something along those lines. It's just a pain and it would be cool if they stumble across some fix in the future.

I think the trick around that is with the "array_merge()" function. It's been awhile so I'm not completely sure, but I believe it's due to the $specialtemplates array being called before global.php.

vertigo jones 11-10-2007 01:14 AM

It's because the query that uses $specialtemplates and populates the datastore variables comes before global_start. I don't really understand why, but I think it has something to do with the hook system not being able to work until the datastore info is available.

Opserty 11-10-2007 08:31 AM

Have you tried the init_startup hook? There is another Datastore fetch executed after it I think. This isn't tested but you could maybe try:

Hook Location: init_startup
PHP Code:

$datastore_fetch[] = "'dropmenu'"


vertigo jones 11-10-2007 08:45 PM

Awesome, thanks man. I haven't tested it either, but it looks like that should work.

--------------- Added [DATE]1194736320[/DATE] at [TIME]1194736320[/TIME] ---------------

Ok, it did work. It added the extra query, but it works.

You have to be careful and make sure it's like this though:

Code:

$datastore_fetch[] = "'dropmenu'";
Doing it without both sets of quotes makes everything (including the admincp) inaccessbile until you go in and correct it in both the plugin table and the datastore entry. They try to warn against it in the code, but I wasn't exactly sure what it meant.

Opserty 11-11-2007 09:03 AM

Ooops yup you need to put it in quotes because otherwise MySQL will read it as a column name instead of a value.

I'll correct it in my original post.

Antivirus 02-13-2008 01:51 AM

The Function build_datastore also has a 3rd parameter which should be mentioned, as it seems all serialized data in the datastore table requires a value of 1...

PHP Code:

#######################################################
/**
* Saves the specified data into the datastore
* @param    string    The name of the datastore item to save
* @param    mixed    The data to be saved
* @param        integer 1 or 0 as to whether this value is to be automatically unserialised on retrieval
*/

function build_datastore($title ''$data ''$unserialize 0

By setting the 3rd param to true, it's no longer necessary to run unserialize like this:
$vbulletin->dropmenu = unserialize($vbulletin->dropmenu);

There'fore we can just access the info from the datastore like this:

PHP Code:

$vbulletin->dropmenu['id'


RobDog888 06-05-2008 05:11 PM

<font color="darkgreen">What if I have my own class object and I want to build cache acessible from it only and not use the $vbulletin object?

Like ...
$myclass->mycache['something']

instead of $vbulletin->mycache['something']

How would I change it so its like that?</font>

briansol 06-06-2008 05:50 AM

With a couple tweaks (probably because this is 2 years old...), i've successfully got my first datastore plugin working :)

Thanks for the write up Ken. Never experienced with the datastore much.


All times are GMT. The time now is 10:47 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.04012 seconds
  • Memory Usage 1,743KB
  • 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_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (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