I have fairly simple requirements, but I'm not sure how to implement them:
How can I guarantee that the "string" is unique? How can I prevent other threads from writing to the table after another thread has read it and has not found the corresponding string element?
Thanks for any advice ..
If you are sure that you cannot use the DB constraint, then use the UNIQUE index in another field, where you store a good cryptic hash of the entire string. I guess MD5 or SHA1 should be enough. Several source control systems (e.g. Git, Mercurial, Monotone, etc.) rely on an extremely low chance of hash collisions.
/, , .
, "" , :
select distinct string from table where ...
, Thread , HashMap , Thread , . , HashMap, . HashMap, , .
, , , . .
Instead of using lock tables, since it is not supported in stored procedures, you can use
START TRANSACTION; SELECT * FROM .... COMMIT;
You just need to make sure that you are using a transaction-safe storage engine, for example InnoDB.
InnoDB
Source: https://habr.com/ru/post/1737155/More articles:Data Structures - language-agnosticASP.NET random slowdowns - c #ошибка C2784: не удалось вывести аргумент шаблона - c++Ошибка при установке Microsoft SharePoint 2010 на компьютере под управлением Windows 7 - windows-7ASP.NET Live Activity Monitor - asp.netsetTimeout in javascript not giving the browser a “respite” - javascripthow to manipulate json response as an object? - jsonGet coordinates of google maps markers - javascriptCleaning list - matlabRuby Rails _without_ ActiveRecord - ruby | fooobar.comAll Articles