serialize object or save var in session?which one is faster and less process?
I'm trying to program web site which can log in into yahoo account and make chat possible. first time I connect to yahoo,their server send some things to me ,these things are necessary for next process,e.g sending pm or receiving it.
I'm developing it by CodeIgniter and curllib and ajax.
Now which way is true,I mean faster, safer and less processing for server?
- Save yahoo var in session and use it on each process or serialize object which contain all thing
- Save it into database and use it on each process or save each var in database and use it开发者_Go百科?
The data: 6 vars should be saved, a request (usually 20~30 chars) variables, an access (usually 20 ~ 30] variables),username variable, includeheader (boolean TRUE / FALSE) variable, debug (boolean TRUE / FALSE) variable and ym (an array of 100 ~ 150 chars) variable.
Data saved in the session is actually serialized to a file by PHP. So there's not really a difference.
However, PHP is not really a good language for chat applications. Something like Node.js would fit much better. Besides that, are you really going to connect+disconnect to yahoo chat on every request? If yes, expect them to block you IP quickly.
精彩评论