mIRC Home    About    Download    Register    News    Help

Print Thread
#258822 02/09/16 11:47 AM
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hi!
I'm creating something lately, a long term project as my time is kinda limited for now.
In that project there is a "database" with registered users and info and other stuff.
I don't have any problem with hashtables, not anymore, i can make, save, load, edit them very easily.. but i was wondering...
Right nw i am using 1 hashtable where each item is a user and data is some info seperated with ~ so i can use spaces in each part of info and still be able to get them seperately with $gettok .
But it would be a lot easier to get the info i need if i had a diff hashtable for each user.
So at last, my question is: should i keep using one hadhtable or try out seperate for each user? Would that make mirc heavy or slower? And apart from that what do you find more efficient and "right".
Thanks!
-OrFeAsGr

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
It depends on the data you want to store and what you are doing to do with it.
if you are going to have unknown data, then your current method is a bad idea because ~ could appear in there, screwing up the tokens. If you're going to have at least two optional data, it's the same idea (with only one optional data, you can put it as the last token).
For accessing data, one hash table per users would be better, but for finding data, you would need to loop through all the hash tables while with the current method, a good $hfind will do the trick, so even efficiency wise, it depends on what you're going to do.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
An alternative would be instead of storing data for each user as a single item, with its data seperated by ~, you could use an item naming convention to break up a user's data into multiple items:

For example lets say your user data was akin to:
Code:
Item: SomeUser Data: John~Doe~20~Male


Instead, use something similar to the following:
Code:
Item: FirstName.SomeUser Data: John
Item: LastName.SomeUser  Data: Doe
Item: Age.SomeUser       Data: 20
Item: Gender.SomeUser    Data: Male


This has the benefit of being able to search and retrieve a user's data using just native identifiers.


I am SReject
My Stuff
Joined: Feb 2015
Posts: 19
Y
Pikka bird
Offline
Pikka bird
Y
Joined: Feb 2015
Posts: 19
In Provision IRC Services I use ':' as a separator.
Never had any problems, will most certainly use the same method for ProvisionIRCd.

This will be executed upon a successful NickServ registration command:
Code:

hadd rnicks %nick $+($5,:,$6,:,$ctime,:,$ctime,:,$live_chost(%nick),:,$live_rhost(%nick),:dW5rbm93bg==,:,$encode($rname(%nick),m))

Format:
password:email:regtime:lastseen:cloakhost:realhost:quitmsg:realname

If, for example, the cloakhost changes, all you need to do is change the 5th position.
But in the end, it all depends on your own personal preference.

Last edited by Y4kuzi; 06/09/16 12:56 AM.

Link Copied to Clipboard