deleting line
#4

How big is your file?
And how many times do you plan to remove the last line from that file?
Once every minute? Once per hour? Or per second?

Even if it's every second, if your file is small you won't have lag.

My script dumps data to a file whenever a change is made in-game.
Like my mission vehicles.
I can park them in another location and the entire file is rewritten from scratch and is 61kB large because it's dumping all data (vehiclemodel, coordinates and rotation, color) about every mission-vehicle on my server into that file.
Writing such a file only takes a fraction of a second, you don't even notice a minor lag-spike.
Even when I'm spamming my /park command, I don't notice any lag.



If you plan to do this with a file which is several megabytes in size, and you wanna do that several times per second, then yes, you'll get lag.
But then you would need to consider moving to a database instead of a file.
Then you can do what you want without rewriting the entire database or file.
Using MySQL for example, you can have one column in a table which holds text (and another to hold the id, like a linenumber).
Then you can easily delete ANY line from that database with a single query, which is even executed in a threaded way, so you won't get any lag as the query will be executed in a separate thread and won't hog your server until it's completed (kinda like a send-and-forget order).
Reply


Messages In This Thread
deleting line - by roi857 - 28.11.2014, 21:23
Re: deleting line - by PowerPC603 - 28.11.2014, 22:00
Re: deleting line - by roi857 - 28.11.2014, 22:26
Re: deleting line - by PowerPC603 - 28.11.2014, 22:54
Re: deleting line - by roi857 - 29.11.2014, 08:41

Forum Jump:


Users browsing this thread: 1 Guest(s)