AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Optimising MySQL: how to cache data? (https://forums.alliedmods.net/showthread.php?t=88089)

Lukass 03-20-2009 10:47

Optimising MySQL: how to cache data?
 
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 ?

Hunter-Digital 03-20-2009 13:20

Re: Optimising MySQL: how to cache data?
 
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 :)

AntiBots 03-20-2009 14:11

Re: Optimising MySQL: how to cache data?
 
You can see here. I use SELECT, INSERT, UPDATE and the 2 ways to get data.

http://forums.alliedmods.net/showpos...&postcount=240

Lukass 03-23-2009 10:18

Re: Optimising MySQL: how to cache data?
 
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.

Hunter-Digital 03-23-2009 16:28

Re: Optimising MySQL: how to cache data?
 
on player connect set the variables...

Code:

new playerStuff[33]
 
...
 
public client_connect(id)
{
      playerStuff[id] = '' /* mysql data... */
}


Lukass 03-23-2009 16:54

Re: Optimising MySQL: how to cache data?
 
I know, but i want to call mysql only on plugin_init(), not on each client_connect.

danielkza 03-23-2009 16:59

Re: Optimising MySQL: how to cache data?
 
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.

Lukass 03-23-2009 17:14

Re: Optimising MySQL: how to cache data?
 
I have only ~160 usernames and passwords. Is it too large amount of data to cache ?

danielkza 03-23-2009 17:24

Re: Optimising MySQL: how to cache data?
 
Quote:

Originally Posted by Lukass (Post 787538)
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?

Lukass 03-25-2009 04:49

Re: Optimising MySQL: how to cache data?
 
Does amxmodx admin_sql plugin caching admin's data ?


All times are GMT -4. The time now is 08:57.

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