Raised This Month: $ Target: $400
 0% 

Optimising MySQL: how to cache data?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lukass
Junior Member
Join Date: Dec 2008
Old 03-20-2009 , 10:47   Optimising MySQL: how to cache data?
Reply With Quote #1

Hi everyone,

I have one MySQL database, witch contains some data, that i requesting on every client_connect. Can i cache it to somewhere, and reload cache on every map change? If it is, how can i do that ? It will increase plugin's performance ?
Lukass is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 03-20-2009 , 13:20   Re: Optimising MySQL: how to cache data?
Reply With Quote #2

you can load your entire database at plugin_init() into variables, disconnect from mysql, then use the variables across your plugin, and yeah, it will improve some performance because the plugin isn't requesting mysql data every time and also the mysql doesn't require CPU power every time (affects server if it's on the same machine)... but it's a slight performance increase tough... but good also
__________________
Hunter-Digital is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-20-2009 , 14:11   Re: Optimising MySQL: how to cache data?
Reply With Quote #3

You can see here. I use SELECT, INSERT, UPDATE and the 2 ways to get data.

http://forums.alliedmods.net/showpos...&postcount=240
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Lukass
Junior Member
Join Date: Dec 2008
Old 03-23-2009 , 10:18   Re: Optimising MySQL: how to cache data?
Reply With Quote #4

But my table contains some usernames and passwords, and i authentificate them, and i don't know, how to do that from variables aka cache.
Lukass is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 03-23-2009 , 16:28   Re: Optimising MySQL: how to cache data?
Reply With Quote #5

on player connect set the variables...

Code:
new playerStuff[33]
 
...
 
public client_connect(id)
{
       playerStuff[id] = '' /* mysql data... */
}
__________________
Hunter-Digital is offline
Lukass
Junior Member
Join Date: Dec 2008
Old 03-23-2009 , 16:54   Re: Optimising MySQL: how to cache data?
Reply With Quote #6

I know, but i want to call mysql only on plugin_init(), not on each client_connect.
Lukass is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 03-23-2009 , 16:59   Re: Optimising MySQL: how to cache data?
Reply With Quote #7

If the DB is using SQLite, or the MySQL server is running on the same box as the server, you shouldn't notice a difference. You'll only be able to cache small databases or subsets of data, once it gets too big things will start to get slow and cumbersome, after all, storing the data is what SQL servers are optimized for, and exactly what AMXX is not made to do.
__________________

Community / No support through PM
danielkza is offline
Lukass
Junior Member
Join Date: Dec 2008
Old 03-23-2009 , 17:14   Re: Optimising MySQL: how to cache data?
Reply With Quote #8

I have only ~160 usernames and passwords. Is it too large amount of data to cache ?
Lukass is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 03-23-2009 , 17:24   Re: Optimising MySQL: how to cache data?
Reply With Quote #9

Quote:
Originally Posted by Lukass View Post
I have only ~160 usernames and passwords. Is it too large amount of data to cache ?
Do you really need to cache it? Are you using threaded queries already? Do you notice any lag on connection or anything like that?
__________________

Community / No support through PM
danielkza is offline
Lukass
Junior Member
Join Date: Dec 2008
Old 03-25-2009 , 04:49   Re: Optimising MySQL: how to cache data?
Reply With Quote #10

Does amxmodx admin_sql plugin caching admin's data ?
Lukass is offline
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 -4. The time now is 08:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode