One more question for you, do functions automatically execute as async or is there a function I dont see for async? None of the functions related to GHMatti.Mysql.Mysql have anything that say async
Edit: I see that you are using a Task function in the example, is that what makes it async?
Using the task functions on different threads makes it async (not really in the truest sense but async for endusers). Just using the task function one the same thread would not make it async (as they are FIFO).
The async calls have the performance issue, due to the IOAwaiter from the CLR, which is in sync with the server thread (which forces it to sleep every call for 40-50ms) ā so just awaiting one async call will create the possibility for it to lag. So to make it async in the simplest case, you put them on different threads, so that they execute independently from each other; so they are async for the server thread. Ideally though I will get them even async on their respective threads, but that requires the use of the Async functions which are due to CLR/FXServer slightly broken.
I can and will try to use the async functions at some point (again), but I fear that many of them are not usable due to them awaiting something where I do not have control over the awaiter; also I will very need to change the FIFO behaviour. The sync functions from the MySqlConnector are themselves just the async functions synchronized.
edit: Alternatively I can rewrite the async functions with my taskscheduler, which should work, but is definately not preferred. On a four core, on default settings it would look like this:
If you merge that back to the super thread it is async, not perfectly, but as much async as I could get them to be with a very basic class. Also none of them are blocking the server thread, so you can go as crazy as you want.
Thank you for this. I just finished putting it in dev, once it goes on the live servers, Iāll be sure to comeback and provide more feedback. I was always noticing some frame lag on the server when we did data syncs using mysql-async
Seems OK, but could you create a wrapper for MySQL-Async API compatibility?
It would be much easier for people to start using it for an already existing code.
(I will do it first:D )
Indeed I have. As @Nick78111 said. Follow the readme. Unless you do some really odd stuff in your code. It replaces it seamlessly or you use the .insert function and do something with the Id returned.
we tend to git clone git@host:repo [category], but thatās of course assuming thereās a resource folder in the root of the output repo.
currently thereās no way to automatically build projects requiring building in the server anyway, and Iām not sure if this repo includes binaries at all (which would be against best practices)
The main project compiles to the resource folder in the bin folder.
Then there is a C# Library, because the server freezes if you link to a BaseScript.dll.
A tiny testing example for both Lua and using the C# Library.
And the replacement resource.
There is a reason why I linked the releases in the first post on the forums, because that is what end users who do not want to manipulate the code should use in the first place.
The most I would do is to put them on seperate branches, and that requires me to maintain then 3 additional branches, where the C# Library and not the Lua implementation represents the master, logically.
I have a question about returned value. Iām using your script ( and I have seen clearly the difference between yours and mysql-async) and I found something interesting. I have read your post but I didnāt find the answer. Iām developing in Lua if youāre asking the question. When I use exports['GHMattiMySQL']:QueryScalar on a null value, I have a table with null value in return value. Is this normal ? ( I adapted my code to your implementation to avoid any problems and it works fine)
Probably because of some oversight on my end. Time to squash a bug. I replicated that behaviour. Thanks a lot. Shouldnāt be longer than 4h needed for the fix to be online.
Thanks for the quick answer. Here is a part of my code if someone wants to know :
local result = exports['GHMattiMySQL']:QueryScalar( -- Insert sql, and parameters here)
if (type(result) == "table" and next(result) == nil) then
-- Do something
else
-- Do something
end
Itās an example. I did not code like that, I swear.
Updated the C# Library and GHMattiMySQL resource to fix a bug discovered by @Scyar_Gameur where DBNull instead of null was returned when QueryScalar selected a null cell.
edit: Accidently saved the compiled release as a Draft, which is now fixed.
Update: Changes are bugged. It now crashes if you select nothing. Resource will be updated in the next hour.