On Mon, May 1, 2006 7:13 am, Ryan A wrote: > basically, I get the username and ip of a person who > logs into a remote site and i have to save this data > (please note that this would be thousands of logins) > so I was wondering if it would be better to save the > username and ip as an empty file where the filename > contains both... > e.g: > <username>:<ip> > or in plain english: > my_username:201.1.1.22 > > This would save me in hundreds/thousands of calls to > the database and would (in theory) be faster as I > would be accessing the filesystem instead of the > DB.... > > Right? Wrong. Just creating all those files is WAY more expensive than letting MySQL open ONE file for its data and appending stuff to that one file. MAYBE if you kept it as a simple text file with fopen(..., 'a') you'd be able to beat MySQL time by a few cycles... But then you'd pay for it by not having any way to actually USE all that data, so what's the point of keeping it? > Sometimes i get no username but just the ip address, > in which case I will first have to see if this IP is > already "logged" by me, and if yes, match the username > to the ip. NO!!! You *CANNOT* assume IP address has *ANYTHING* to do with what user is there! IP address is USELESS for identification/authentication of users in an HTTP environment. > All usernames:ips expire in 1-24 hrs, I will be > running a cron to 'cull' these dead logins. Then you DEFINITELY want to use the database, which will make this MUCH easier. > Am I on the right track or is it too much of a hassle > and just go in for the database option? You should be able to write your version in an hour, and debug it in a day, and then benchmark it... But you're almost-for-sure wasting your time and you should just use DB. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php