Compare commits
No commits in common. "6786ab5be5d9b2acf7dee97fc68bce4fa3d8f138" and "025c26551a280fbe78dd16adbb5bb47d206cf032" have entirely different histories.
6786ab5be5
...
025c26551a
Binary file not shown.
BIN
ArmaRAMDb_x64.so
BIN
ArmaRAMDb_x64.so
Binary file not shown.
@ -1,48 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_addTask
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Add task to queue.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Type of task <STRING>
|
|
||||||
* 1: Name of stored key <STRING> (default: "")
|
|
||||||
* 2: Name of stored hash key field <STRING> (default: "")
|
|
||||||
* 3: Index of stored value in list <STRING> (default: -1)
|
|
||||||
* 4: Value to store in key [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
* 5: Name of function to return data <STRING> (default: "")
|
|
||||||
* 6: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 7: NetID of target to return data from function <STRING> (default: "")
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["hgetall", "", "", -1, [], "ramdb_db_fnc_test", false] call ramdb_db_fnc_addTask (Server or Singleplayer Only)
|
|
||||||
* ["hgetallid", getPlayerUID player, "", -1, [], "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_addTask", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_taskType", "", [""]], ["_key", "", [""]], ["_keyField", "", [""]], ["_index", -1, [0]], ["_value", [], [[]]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
|
|
||||||
|
|
||||||
private _task = [_taskType, _key, _keyField, _index, _value, _function, _call, _netId];
|
|
||||||
|
|
||||||
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_addTask' Added Task '%1' to Queue", _task];
|
|
||||||
|
|
||||||
GVAR(taskQueue) pushBack _task;
|
|
||||||
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_addTask' Queue: %1", GVAR(taskQueue)];
|
|
||||||
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_addTask' Queue Size: %1", count GVAR(taskQueue)];
|
|
||||||
|
|
||||||
if !(GVAR(isProcessing)) then { [] spawn FUNC(processQueue); };
|
|
@ -1,35 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_delete
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Delete stored key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [getPlayerUID player] call ramdb_db_fnc_delete (Server or Singleplayer Only)
|
|
||||||
* [getPlayerUID player] remoteExecCall ["ramdb_db_fnc_delete", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]]];
|
|
||||||
|
|
||||||
if (_key == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_delete' Invalid Input for Key '%1'", _key]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["del", [_key]];
|
|
@ -1,66 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
@file Title: ArmaRAMDb Framework by Creedcoder, J.Schmidt
|
|
||||||
@file Version: 0.1
|
|
||||||
@file Name: fnc_fetch.sqf
|
|
||||||
@file Author: Creedcoder, J.Schmidt
|
|
||||||
@file edit: 03.25.2024
|
|
||||||
Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
|
|
||||||
Do not edit without permission!
|
|
||||||
|
|
||||||
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlikes 4.0 International License.
|
|
||||||
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to Creative Commons,
|
|
||||||
444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
|
|
||||||
|
|
||||||
Fetch from DB:
|
|
||||||
ramdb_db_fetch_array
|
|
||||||
|
|
||||||
["uniqueID", "function", "index", "indextotal", "datachunk", "call", "netId"]
|
|
||||||
*/
|
|
||||||
|
|
||||||
diag_log _this;
|
|
||||||
|
|
||||||
params ["_uniqueID", "_function", "_index", "_total", "_datachunk", "_call", "_netId"];
|
|
||||||
private _dataString = "";
|
|
||||||
private _index_array = [];
|
|
||||||
private _count_total = -1;
|
|
||||||
|
|
||||||
// _uniqueID = parseNumber _uniqueID;
|
|
||||||
// _function
|
|
||||||
// _index = parseNumber _index;
|
|
||||||
// _total = parseNumber _total;
|
|
||||||
// _datachunk
|
|
||||||
// _call
|
|
||||||
// _netId
|
|
||||||
|
|
||||||
ramdb_db_fetch_array pushBackUnique [_uniqueID, _function, _index, _total, _datachunk, _call, _netId];
|
|
||||||
|
|
||||||
_count_total = {
|
|
||||||
if (_uniqueID == _x select 0) then {
|
|
||||||
_index_array pushBackUnique [_x select 2, _x select 4];
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} count ramdb_db_fetch_array;
|
|
||||||
|
|
||||||
if (_count_total == _total) then {
|
|
||||||
_index_array sort true;
|
|
||||||
for "_i" from 0 to (_total - 1) do {
|
|
||||||
_dataString = _dataString + ((_index_array select _i) select 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
diag_log _dataString;
|
|
||||||
|
|
||||||
// Old direct execution
|
|
||||||
// (parseSimpleArray _dataString) call (missionNamespace getVariable [_function, {
|
|
||||||
// hint "Function does not exist!";
|
|
||||||
// }]);
|
|
||||||
|
|
||||||
[_uniqueID, _function, _call, (parseSimpleArray _dataString), _netId] call FUNC(handler);
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
ramdb_db_fetch_array = ramdb_db_fetch_array select {!((_x select 0) in [_uniqueID])};
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_get
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get value of stored key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Name of function to return data <STRING> (default: "")
|
|
||||||
* 2: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 3: NetID of target to return data from function <STRING> (default: "")
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [getPlayerUID player, "ramdb_db_fnc_test"] call ramdb_db_fnc_get (Server or Singleplayer Only)
|
|
||||||
* [getPlayerUID player, "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_get", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_key == "" || _function == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_get' Invalid Input for Key '%1' or Function '%2'", _key, _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["get", [_key, _function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["get", [_key, _function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["get", [_key, _function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,47 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_handler
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Handle data from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: UniqueID for data chunk <STRING> (default: "")
|
|
||||||
* 1: Name of function to return data <STRING> (default: "")
|
|
||||||
* 2: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 3: Data from key [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
* 4: NetID of target to return data to from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* [uniqueID, function, call, data, object] <ARRAY>
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["0123456789", "ramdb_db_fnc_test", false, ["Hello World!"]] call ramdb_db_fnc_handler (Server or Singleplayer Only)
|
|
||||||
* ["0123456789", "ramdb_db_fnc_test", false, ["Hello World!"], netId player] remoteExecCall ["ramdb_db_fnc_handler", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_uniqueID", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_data", [], [[]]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_function == "" || count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_handler' Invalid Input for Function '%1' or Data '%2'", _function, _data]; };
|
|
||||||
|
|
||||||
private _func = call compile format ["%1", _function];
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
private _target = objectFromNetId _netId;
|
|
||||||
|
|
||||||
if (_call) then { _data remoteExecCall [_function, _target, false]; } else { _data remoteExec [_function, _target, false]; };
|
|
||||||
} else {
|
|
||||||
if (_call) then { _data call _func; } else { _data spawn _func; };
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashGet
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get value of field in hash stored in key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored field in hash <STRING> (default: "")
|
|
||||||
* 1: Name of function to return data <STRING> (default: "")
|
|
||||||
* 2: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 3: NetID of target to return data from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["loadout", "ramdb_db_fnc_test", false] call ramdb_db_fnc_hashGet (Server or Singleplayer Only)
|
|
||||||
* ["loadout", "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_hashGet", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_keyField", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_keyField == "" || _function == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGet' Invalid Input for KeyField '%1' or Function '%2'", _keyField, _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hget", [_keyField, _function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hget", [_keyField, _function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hget", [_keyField, _function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,48 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashGetAll
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get all fields and values of hash stored in key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of function to return data <STRING> (default: "")
|
|
||||||
* 1: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 2: NetID of target to return data from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["ramdb_db_fnc_test", false] call ramdb_db_fnc_hashGetAll (Server or Singleplayer Only)
|
|
||||||
* ["ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_hashGetAll", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_function isEqualTo "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAll' Invalid Input for Function '%1'", _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetall", [_function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetall", [_function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetall", [_function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashGetAllId
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get all fields and values of hash stored in key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key with hash <STRING> (default: "")
|
|
||||||
* 1: Name of function to return data <STRING> (default: "")
|
|
||||||
* 2: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 3: NetID of target to return data from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [getPlayerUID player, "ramdb_db_fnc_test", false] call ramdb_db_fnc_hashGetAllId (Server or Singleplayer Only)
|
|
||||||
* [getPlayerUID player, "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_hashGetAllId", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_key == "" || _function == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAllId' Invalid Input for Key '%1' or Function '%2'", _key, _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetallid", [_key, _function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetallid", [_key, _function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetallid", [_key, _function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,50 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashGetId
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get value of field in hash stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key with hash <STRING> (default: "")
|
|
||||||
* 1: Name of stored field in hash <STRING> (default: "")
|
|
||||||
* 2: Name of function to return data <STRING> (default: "")
|
|
||||||
* 3: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 4: NetID of target to return data from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [getPlayerUID player, "loadout", "ramdb_db_fnc_test", false] call ramdb_db_fnc_hashGetId (Server or Singleplayer Only)
|
|
||||||
* [getPlayerUID player, "loadout", "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_hashGetId", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_keyField", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_key == "" || _keyField == "" || _function == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetId' Invalid Input for Key '%1', KeyField '%2' or Function '%3'", _key, _keyField, _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetid", [_key, _keyField, _function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetid", [_key, _keyField, _function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["hgetid", [_key, _keyField, _function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashSet
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Set value of field in hash stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored field in hash <STRING> (default: "")
|
|
||||||
* 1: Value to store in hash field [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["loadout", [getUnitLoadout player]] call ramdb_db_fnc_hashSet (Server or Singleplayer Only)
|
|
||||||
* ["loadout", [getUnitLoadout player]] remoteExecCall ["ramdb_db_fnc_hashSet", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_keyField", "", [""]], ["_data", [], [[]]]];
|
|
||||||
|
|
||||||
if (_keyField == "" || count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSet' Invalid Input for KeyField '%1' or Data '%2'", _keyField, _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["hset", [_keyField, _data]];
|
|
@ -1,35 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashSetBulk
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Set fields and values in hash stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Fields and Values to store in hash [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] call ramdb_db_fnc_hashSetBulk (Server or Singleplayer Only)
|
|
||||||
* ["loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] remoteExecCall ["ramdb_db_fnc_hashSetBulk", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_data", [], [[]]]];
|
|
||||||
|
|
||||||
if (count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetBulk' Invalid Input for Data '%1'", _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["hset", _data];
|
|
@ -1,37 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashSetId
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Set value of field in hash stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key with hash <STRING> (default: "")
|
|
||||||
* 1: Name of stored hash key field <STRING> (default: "")
|
|
||||||
* 2: Value to store in hash field [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [getPlayerUID player, "loadout", [getUnitLoadout player]] call ramdb_db_fnc_hashSetId (Server or Singleplayer Only)
|
|
||||||
* [getPlayerUID player, "loadout", [getUnitLoadout player]] remoteExecCall ["ramdb_db_fnc_hashSetId", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_keyField", "", [""]], ["_data", [], [[]]]];
|
|
||||||
|
|
||||||
if (_key == "" || _keyField == "" || count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetId' Invalid Input for Key '%1', KeyField '%2' or Data '%3'", _key, _keyField, _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["hsetid", [_key, _keyField, _data]];
|
|
@ -1,35 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_hashSetIdBulk
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Set fields and values in hash stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Fields and Values to store in hash [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [getPlayerUID player, "loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] call ramdb_db_fnc_hashSetIdBulk (Server or Singleplayer Only)
|
|
||||||
* [getPlayerUID player, "loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] remoteExecCall ["ramdb_db_fnc_hashSetIdBulk", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_data", [], [[]]]];
|
|
||||||
|
|
||||||
if (count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetIdBulk' Invalid Input for Data '%1'", _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["hsetid", _data];
|
|
@ -1,37 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_init
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Initial Extension settings.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
ramdb_db_buffer = 10240;
|
|
||||||
|
|
||||||
private _dll = "ArmaRAMDb" callExtension ["version", []];
|
|
||||||
|
|
||||||
diag_log text (format ["ArmaRAMDb: DLL Version %1 found", _dll]);
|
|
||||||
diag_log text "ArmaRAMDb: Functions loaded and Initializtion completed!";
|
|
||||||
diag_log text (format ["ArmaRAMDb: Buffer size set to %1 Bytes", ramdb_db_buffer]);
|
|
||||||
diag_log text "ArmaRAMDb: Ready for use!";
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_listAdd
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Add element to list stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Value to insert into key [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["events", ["Server state saved to DB 071620241600"]] call ramdb_db_fnc_listAdd (Server or Singleplayer Only)
|
|
||||||
* ["events", ["Server state saved to DB 071620241600"]] remoteExecCall ["ramdb_db_fnc_listAdd", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_data", [], [[]]]];
|
|
||||||
|
|
||||||
if (_key == "" || count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listAdd' Invalid Input for Key '%1' or Data '%2'", _key, _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["listadd", [_key, _data]];
|
|
@ -1,50 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_listGet
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get element of list stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Index of stored value in list <NUMBER> (default: -1)
|
|
||||||
* 2: Name of function to return data <STRING> (default: "")
|
|
||||||
* 3: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 4: NetID of target to return data from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["events", 0, "ramdb_db_fnc_test", false] call ramdb_db_fnc_listGet (Server or Singleplayer Only)
|
|
||||||
* ["events", 0, "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_listGet", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_index", -1, [0]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_key == "" || _function == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listGet' Invalid Input for Key '%1' or Function '%2'", _key, _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["listidx", [_key, _index, _function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["listidx", [_key, _index, _function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["listidx", [_key, _index, _function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_listLoad
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Get all elements of list stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Name of function to return data <STRING> (default: "")
|
|
||||||
* 2: Unscheduled environment <BOOL> (default: false)
|
|
||||||
* 3: NetID of target to return data from function <STRING> (default: nil)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["events", "ramdb_db_fnc_test", false] call ramdb_db_fnc_listLoad (Server or Singleplayer Only)
|
|
||||||
* ["events", "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_listLoad", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", nil, [""]]];
|
|
||||||
|
|
||||||
if (_key == "" || _function == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listLoad' Invalid Input for Key '%1' or Function '%2'", _key, _function]; };
|
|
||||||
|
|
||||||
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
|
|
||||||
if (_call) then {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["listrng", [_key, 0, -1, _function, _netId, _call]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["listrng", [_key, 0, -1, _function, _netId]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_return = "ArmaRAMDb" callExtension ["listrng", [_key, 0, -1, _function]];
|
|
||||||
[(_return select 0)] call FUNC(scheduler);
|
|
||||||
};
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_listRemove
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Remove element of list stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Index of stored value in list <NUMBER> (default: -1)
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["events", 0] call ramdb_db_fnc_listRemove (Server or Singleplayer Only)
|
|
||||||
* ["events", 0] remoteExecCall ["ramdb_db_fnc_listRemove", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_index", -1, [0]]];
|
|
||||||
|
|
||||||
if (_key == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listRemove' Invalid Input for Key '%1'", _key]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["listrem", [_key, _index]];
|
|
@ -1,37 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_listSet
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Set element of list stored at key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Index of stored value in list <NUMBER> (default: -1)
|
|
||||||
* 2: Value to set for index [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["events", 0, ["Hello World!"]] call ramdb_db_fnc_listSet (Server or Singleplayer Only)
|
|
||||||
* ["events", 0, ["Hello World!"]] remoteExecCall ["ramdb_db_fnc_listSet", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_index", -1, [0]], ["_data", [], [[]]]];
|
|
||||||
|
|
||||||
if (_key == "" || count _data == 0) exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listSet' Invalid Input for Key '%1' or Data '%2'", _key, _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["listset", [_key, _index, _data]];
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
systemChat format ["Thank you for using the %1", 'ADDON'];
|
|
@ -1,69 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_processQueue
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Process queue of tasks.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [] spawn ramdb_db_fnc_processQueue (Server or Singleplayer Only)
|
|
||||||
* [] remoteExec ["ramdb_db_fnc_processQueue", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
GVAR(isProcessing) = true;
|
|
||||||
|
|
||||||
while { count GVAR(taskQueue) > 0} do {
|
|
||||||
private _task = GVAR(taskQueue) deleteAt 0;
|
|
||||||
private _taskType = _task select 0;
|
|
||||||
private _key = _task select 1;
|
|
||||||
private _keyField = _task select 2;
|
|
||||||
private _index = _task select 3;
|
|
||||||
private _value = _task select 4;
|
|
||||||
private _function = _task select 5;
|
|
||||||
private _call = _task select 6;
|
|
||||||
private _netId = _task select 7;
|
|
||||||
|
|
||||||
diag_log text format ["Initializing Task: %1", _task];
|
|
||||||
|
|
||||||
switch (_taskType) do {
|
|
||||||
case "get": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(get); };
|
|
||||||
case "set": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _value] call FUNC(set); };
|
|
||||||
case "del": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key] call FUNC(delete); };
|
|
||||||
case "hget": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_keyField, _function, _call, _netId] call FUNC(hashGet); };
|
|
||||||
case "hgetid": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _keyField, _function, _call, _netId] call FUNC(hashGetId); };
|
|
||||||
case "hgetall": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_function, _call, _netId] call FUNC(hashGetAll); };
|
|
||||||
case "hgetallid": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(hashGetAllId); };
|
|
||||||
case "hset": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_keyField, _value] call FUNC(hashSet); };
|
|
||||||
case "hsetbulk": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_value] call FUNC(hashSetBulk); };
|
|
||||||
case "hsetid": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _keyField, _value] call FUNC(hashSetId); };
|
|
||||||
case "hsetidbulk": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_value] call FUNC(hashSetIdBulk); };
|
|
||||||
case "listadd": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _value] call FUNC(listAdd); };
|
|
||||||
case "listidx": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index, _function, _call, _netId] call FUNC(listGet); };
|
|
||||||
case "listrng": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(listLoad); };
|
|
||||||
case "listrem": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index] call FUNC(listRemove); };
|
|
||||||
case "listset": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index, _value] call FUNC(listSet); };
|
|
||||||
};
|
|
||||||
|
|
||||||
sleep 1;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GVAR(isProcessing) = false;
|
|
@ -1,31 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_save
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Save to disc.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* [] call ramdb_db_fnc_save (Server or Singleplayer Only)
|
|
||||||
* [] remoteExecCall ["ramdb_db_fnc_save", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["save", []];
|
|
@ -1,48 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_scheduler
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Scheduled Environment for extension.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Task ID from extension <STRING> (default: "")
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["071620241600_get"] call ramdb_db_fnc_scheduler (Server or Singleplayer Only)
|
|
||||||
* ["071620241600_get"] remoteExecCall ["ramdb_db_fnc_scheduler", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
private _params = call compile format ["%1", (_this select 0)];
|
|
||||||
private _taskID = _params select 0;
|
|
||||||
private _function = _params select 1;
|
|
||||||
private _array = _taskID splitString "_";
|
|
||||||
private _id = _array select 0;
|
|
||||||
private _taskType = _array select 1;
|
|
||||||
private _addTaskIDToMap = {
|
|
||||||
params ["_taskType", "_taskID"];
|
|
||||||
|
|
||||||
private _varName = format ["ramdb_db_%1_map", _taskType];
|
|
||||||
private _taskMap = missionNamespace getVariable [_varName, createHashMap];
|
|
||||||
_taskMap set [_taskID, _function];
|
|
||||||
|
|
||||||
missionNamespace setVariable [_varName, _taskMap];
|
|
||||||
_myHashMap = missionNamespace getVariable [_varName, createHashMap];
|
|
||||||
};
|
|
||||||
|
|
||||||
[_taskType, _taskID] call _addTaskIDToMap;
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_set
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Set value of stored key from DB.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Name of stored key <STRING> (default: "")
|
|
||||||
* 1: Value to store in key [<ARRAY|STRING|NUMBER|BOOL>] (default: [])
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* N/A
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["test", ["Hello World!"]] call ramdb_db_fnc_set (Server or Singleplayer Only)
|
|
||||||
* ["test", ["Hello World!"]] remoteExecCall ["ramdb_db_fnc_set", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
params [["_key", "", [""]], ["_data", "", [[]]]];
|
|
||||||
|
|
||||||
if (_key == "" || _data == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_set' Invalid Input for Key '%1' or Data '%2'", _key, _data]; };
|
|
||||||
|
|
||||||
"ArmaRAMDb" callExtension ["set", [_key, _data]];
|
|
@ -1,34 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: ramdb_db_fnc_test
|
|
||||||
* Author: Creedcoder, J.Schmidt
|
|
||||||
* Edit: 07.15.2024
|
|
||||||
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
|
|
||||||
*
|
|
||||||
* Do not edit without permission!
|
|
||||||
*
|
|
||||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
||||||
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
|
|
||||||
* PO Box 1866, Mountain View, CA 94042
|
|
||||||
*
|
|
||||||
* [Description]
|
|
||||||
* Test function.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Value <ARRAY|STRING|NUMBER|BOOL>
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* <ARRAY|STRING|NUMBER|BOOL> Value
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ["Hello World!"] spawn ramdb_db_fnc_test (Server or Singleplayer Only)
|
|
||||||
* ["Hello World!"] remoteExec ["ramdb_db_fnc_test", 2, false] (Multiplayer Only)
|
|
||||||
*
|
|
||||||
* Public: Yes
|
|
||||||
*/
|
|
||||||
|
|
||||||
_res = _this;
|
|
||||||
ramdb_db_test = _res;
|
|
||||||
|
|
||||||
hint format ["%1", _res];
|
|
@ -1 +0,0 @@
|
|||||||
#include "..\script_component.hpp"
|
|
Binary file not shown.
Binary file not shown.
@ -1,57 +1,37 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace ArmaRAMDb
|
namespace ArmaRAMDb
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
{
|
||||||
internal class HashStore
|
internal class HashStore
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, string>> _hashTables = RAMDb._hashTables;
|
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, string>> _hashTables = RAMDb._hashTables;
|
||||||
|
|
||||||
public static async Task HashDelete(string tableName)
|
public static bool HashDelete(string tableName)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
var result = _hashTables.TryRemove(tableName, out _);
|
||||||
bool result = _hashTables.TryRemove(tableName, out _);
|
|
||||||
|
|
||||||
Main.Log($"HashDelete: {tableName} - Success: {result}", "debug");
|
Main.Log($"HashDelete: {tableName} - Success: {result}", "debug");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task HashGet(string tableName, string key, string function, string uniqueID, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
public static string HashGet(string tableName, string key)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(tableName) || string.IsNullOrEmpty(key) || string.IsNullOrEmpty(function))
|
|
||||||
{
|
|
||||||
Main.Log($"ArmaRAMDb 'tableName, 'key' or 'function' cannot be empty", "debug");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_hashTables.TryGetValue(tableName, out var table))
|
if (_hashTables.TryGetValue(tableName, out var table))
|
||||||
{
|
{
|
||||||
string data = table.TryGetValue(key, out string value) ? value : string.Empty;
|
string data = table.TryGetValue(key, out string value) ? value : string.Empty;
|
||||||
Main.Log($"HashGet: {tableName} - {key}", "debug");
|
Main.Log($"HashGet: {tableName} - {key}", "debug");
|
||||||
Main.Log($"Value: {data}", "debug");
|
Main.Log($"Value: {data}", "debug");
|
||||||
|
return data;
|
||||||
Utils.CheckByteCount(uniqueID, data, function, entity, Convert.ToBoolean(call), bufferSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Main.Log($"Table not found: {tableName}", "debug");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"Table not found: {tableName}", "debug");
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task HashGetAllAsync(string tableName, string function, string uniqueId, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
public static Dictionary<string, string> HashGetAll(string tableName)
|
||||||
{
|
{
|
||||||
Main.Log($"Getting contents for table: {tableName}", "debug");
|
Main.Log($"Getting contents for table: {tableName}", "debug");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(tableName) || string.IsNullOrEmpty(function))
|
|
||||||
{
|
|
||||||
Main.Log($"ArmaRAMDb 'tableName' or 'function' cannot be empty", "debug");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_hashTables.TryGetValue(tableName, out var table))
|
if (_hashTables.TryGetValue(tableName, out var table))
|
||||||
{
|
{
|
||||||
var contents = table.ToDictionary(kv => kv.Key, kv => kv.Value);
|
var contents = table.ToDictionary(kv => kv.Key, kv => kv.Value);
|
||||||
@ -62,53 +42,45 @@ namespace ArmaRAMDb
|
|||||||
Main.Log($"Key: {entry.Key}, Value: {entry.Value}", "debug");
|
Main.Log($"Key: {entry.Key}, Value: {entry.Value}", "debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
string data = string.Join(",", contents.Select(kv => $"[\"{kv.Key}\",{kv.Value}]"));
|
return contents;
|
||||||
Utils.CheckByteCount(uniqueId, $"[{data}]", function, entity, Convert.ToBoolean(call), bufferSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Main.Log($"Table {tableName} not found", "debug");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"Table {tableName} not found", "debug");
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task HashRemoveAsync(string tableName, string key)
|
public static bool HashRemove(string tableName, string key)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_hashTables.TryGetValue(tableName, out var table))
|
if (_hashTables.TryGetValue(tableName, out var table))
|
||||||
{
|
{
|
||||||
table.TryRemove(key, out _);
|
var result = table.TryRemove(key, out _);
|
||||||
}
|
Main.Log($"HashRemove: {tableName} - {key} - Success: {result}", "debug");
|
||||||
else
|
return result;
|
||||||
{
|
|
||||||
Main.Log($"Table not found: {tableName}", "debug");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"Table {tableName} or Key {key} not found", "debug");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task HashSetBulkAsync(string tableName, Dictionary<string, string> values)
|
public static bool HashSet(string tableName, string key, string value)
|
||||||
{
|
{
|
||||||
var table = _hashTables.GetOrAdd(tableName, _ => new ConcurrentDictionary<string, string>());
|
var table = _hashTables.GetOrAdd(tableName, _ => new ConcurrentDictionary<string, string>());
|
||||||
|
table.AddOrUpdate(key, value, (_, _) => value);
|
||||||
|
|
||||||
await Task.Yield();
|
Main.Log($"HashSet: {tableName} - {key} - {value}", "debug");
|
||||||
|
return true;
|
||||||
foreach (var kv in values)
|
|
||||||
{
|
|
||||||
var value = kv.Value;
|
|
||||||
if (value.StartsWith('[') && value.EndsWith(']'))
|
|
||||||
{
|
|
||||||
table.AddOrUpdate(kv.Key, value, (_, _) => value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
table.AddOrUpdate(kv.Key, $"[\"{value}\"]", (_, _) => $"[\"{value}\"]");
|
|
||||||
}
|
|
||||||
Main.Log($"HashSet: {tableName} - {kv.Key} - {value}", "debug");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task HashSetAsync(string tableName, string key, string value)
|
public static bool HashSetBulk(string tableName, Dictionary<string, string> values)
|
||||||
{
|
{
|
||||||
await HashSetBulkAsync(tableName, new Dictionary<string, string> { { key, value } });
|
var table = _hashTables.GetOrAdd(tableName, _ => new ConcurrentDictionary<string, string>());
|
||||||
|
foreach (var kv in values)
|
||||||
|
{
|
||||||
|
table.AddOrUpdate(kv.Key, kv.Value, (_, _) => kv.Value);
|
||||||
|
Main.Log($"HashSetBulk: {tableName} - {kv.Key} - {kv.Value}", "debug");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,50 +1,33 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace ArmaRAMDb
|
namespace ArmaRAMDb
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
{
|
||||||
internal class KeyValueStore
|
internal class KeyValueStore
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<string, string> _keyValues = RAMDb._keyValues;
|
private static readonly ConcurrentDictionary<string, string> _keyValues = RAMDb._keyValues;
|
||||||
|
|
||||||
public static async Task GetAsync(string key, string function, string uniqueId, string entity = null, string call = "false", int buffersize = Main.ARDB_BUFFERSIZE)
|
public static string GetValue(string key)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(function))
|
|
||||||
{
|
|
||||||
Main.Log($"ArmaRAMDb 'key' or 'function' cannot be empty", "debug");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
string value = _keyValues.TryGetValue(key, out string data) ? data : string.Empty;
|
string value = _keyValues.TryGetValue(key, out string data) ? data : string.Empty;
|
||||||
|
|
||||||
Main.Log($"GetValue: {key} - Value: {value}", "debug");
|
Main.Log($"GetValue: {key} - Value: {value}", "debug");
|
||||||
|
return value;
|
||||||
Utils.CheckByteCount(uniqueId, value, function, entity, Convert.ToBoolean(call), buffersize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task SetAsync(string key, string value)
|
public static bool DeleteValue(string key)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (value.StartsWith('[') && value.EndsWith(']'))
|
|
||||||
{
|
|
||||||
_keyValues.AddOrUpdate(key, value, (_, _) => value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_keyValues.AddOrUpdate(key, $"[\"{value}\"]", (_, _) => $"[\"{value}\"]");
|
|
||||||
}
|
|
||||||
|
|
||||||
Main.Log($"SetValue: {key} - Value: {value}", "debug");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task DeleteAsync(string key)
|
|
||||||
{
|
|
||||||
await Task.Yield();
|
|
||||||
var result = _keyValues.TryRemove(key, out _);
|
var result = _keyValues.TryRemove(key, out _);
|
||||||
|
|
||||||
Main.Log($"DeleteValue: {key} - Success: {result}", "debug");
|
Main.Log($"DeleteValue: {key} - Success: {result}", "debug");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool SetValue(string key, string value)
|
||||||
|
{
|
||||||
|
_keyValues.AddOrUpdate(key, value, (_, _) => value);
|
||||||
|
|
||||||
|
Main.Log($"SetValue: {key} - Value: {value}", "debug");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,118 +1,107 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace ArmaRAMDb
|
namespace ArmaRAMDb
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
{
|
||||||
internal class ListStore
|
internal class ListStore
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<string, List<string>> _lists = RAMDb._lists;
|
private static readonly ConcurrentDictionary<string, List<string>> _lists = RAMDb._lists;
|
||||||
|
|
||||||
public static async Task ListAddAsync(string listName, string value)
|
public static bool ListAdd(string listName, string value)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
if (_lists.TryGetValue(listName, out var list))
|
||||||
|
|
||||||
lock (_lists)
|
|
||||||
{
|
{
|
||||||
if (!_lists.TryGetValue(listName, out List<string> list))
|
|
||||||
{
|
|
||||||
list = [];
|
|
||||||
_lists[listName] = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (list)
|
lock (list)
|
||||||
{
|
{
|
||||||
if (value.StartsWith('[') && value.EndsWith(']'))
|
list.Add(value);
|
||||||
{
|
|
||||||
list.Add(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list.Add($"[\"{value}\"]");
|
|
||||||
}
|
|
||||||
Main.Log($"ListAdd: {listName} - Value: {value}", "debug");
|
Main.Log($"ListAdd: {listName} - Value: {value}", "debug");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"List not found: {listName}", "debug");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ListIndexAsync(string listName, string index, string function, string uniqueId, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
public static bool ListDelete(string listName)
|
||||||
|
{
|
||||||
|
var result = _lists.TryRemove(listName, out _);
|
||||||
|
|
||||||
|
Main.Log($"ListDelete: {listName} - Success: {result}", "debug");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ListIndex(string listName, int index)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_lists.TryGetValue(listName, out var list))
|
if (_lists.TryGetValue(listName, out var list))
|
||||||
{
|
{
|
||||||
lock (list)
|
lock (list)
|
||||||
{
|
{
|
||||||
int idx = int.Parse(index);
|
string value = index >= 0 && index < list.Count ? list[index] : string.Empty;
|
||||||
string value = idx >= 0 && idx < list.Count ? list[idx] : string.Empty;
|
Main.Log($"ListIndex: {listName} - Index: {index} - Value: {value}", "debug");
|
||||||
Main.Log($"ListIndex: {listName} - Index: {idx} - Value: {value}", "debug");
|
return value;
|
||||||
Utils.CheckByteCount(uniqueId, value, function, entity, Convert.ToBoolean(call), bufferSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"List not found: {listName}", "debug");
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ListRangeAsync(string listName, string startIndex, string endIndex, string function, string uniqueId, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
public static List<string> ListRange(string listName, int startIndex, int endIndex)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_lists.TryGetValue(listName, out var list))
|
if (_lists.TryGetValue(listName, out var list))
|
||||||
{
|
{
|
||||||
lock (list)
|
lock (list)
|
||||||
{
|
{
|
||||||
int start = int.Parse(startIndex);
|
startIndex = Math.Max(0, startIndex);
|
||||||
int end = int.Parse(endIndex);
|
endIndex = Math.Min(list.Count - 1, endIndex);
|
||||||
start = Math.Max(0, start);
|
|
||||||
end = Math.Min(list.Count - 1, end);
|
|
||||||
|
|
||||||
if (start <= end)
|
if (startIndex <= endIndex)
|
||||||
{
|
{
|
||||||
int count = end - start + 1;
|
int count = endIndex - startIndex + 1;
|
||||||
var value = list.GetRange(start, count);
|
var value = list.GetRange(startIndex, count);
|
||||||
string data = string.Join(",", value);
|
Main.Log($"ListRange: {listName} - StartIndex: {startIndex} - EndIndex: {endIndex} - Count: {count}", "debug");
|
||||||
Main.Log($"ListRange: {listName} - StartIndex: {start} - EndIndex: {end} - Count: {count}", "debug");
|
return value;
|
||||||
Utils.CheckByteCount(uniqueId, $"[{data}]", function, entity, Convert.ToBoolean(call), bufferSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"List not found: {listName}", "debug");
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ListSetAsync(string listName, string index, string value)
|
public static bool ListRemove(string listName, string value)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_lists.TryGetValue(listName, out var list))
|
|
||||||
{
|
|
||||||
lock (list)
|
|
||||||
{
|
|
||||||
int idx = int.Parse(index);
|
|
||||||
if (idx >= 0 && idx < list.Count)
|
|
||||||
{
|
|
||||||
if (value.StartsWith('[') && value.EndsWith(']'))
|
|
||||||
{
|
|
||||||
list[idx] = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list[idx] = $"[\"{value}\"]";
|
|
||||||
}
|
|
||||||
Main.Log($"ListSet: {listName} - Index: {idx} - Value: {value}", "debug");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task ListRemoveAsync(string listName, string value)
|
|
||||||
{
|
|
||||||
await Task.Yield();
|
|
||||||
|
|
||||||
if (_lists.TryGetValue(listName, out var list))
|
if (_lists.TryGetValue(listName, out var list))
|
||||||
{
|
{
|
||||||
lock (list)
|
lock (list)
|
||||||
{
|
{
|
||||||
int removedCount = list.RemoveAll(item => item == value);
|
int removedCount = list.RemoveAll(item => item == value);
|
||||||
Main.Log($"ListRemove: {listName} - Value: {value} - Removed Count: {removedCount}", "debug");
|
Main.Log($"ListRemove: {listName} - Value: {value} - Removed Count: {removedCount}", "debug");
|
||||||
|
return removedCount > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Log($"List not found: {listName}", "debug");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ListSet(string listName, int index, string value)
|
||||||
|
{
|
||||||
|
if (_lists.TryGetValue(listName, out var list))
|
||||||
|
{
|
||||||
|
lock (list)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < list.Count)
|
||||||
|
{
|
||||||
|
list[index] = value;
|
||||||
|
Main.Log($"ListSet: {listName} - Index: {index} - Value: {value}", "debug");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Main.Log($"List not found: {listName}", "debug");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,9 +2,7 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace ArmaRAMDb
|
namespace ArmaRAMDb
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
{
|
||||||
public class CallContext
|
public class CallContext
|
||||||
{
|
{
|
||||||
@ -18,7 +16,6 @@ namespace ArmaRAMDb
|
|||||||
public class Main
|
public class Main
|
||||||
{
|
{
|
||||||
private const string ARDB_VERSION = "1.0.0";
|
private const string ARDB_VERSION = "1.0.0";
|
||||||
public const int ARDB_BUFFERSIZE = 1024;
|
|
||||||
public static string ARDB_LOGFOLDER { get; private set; } = "\\@ramdb\\logs";
|
public static string ARDB_LOGFOLDER { get; private set; } = "\\@ramdb\\logs";
|
||||||
public static bool ARDB_DEBUG {get; private set; } = false;
|
public static bool ARDB_DEBUG {get; private set; } = false;
|
||||||
public static bool ARDB_INITCHECK {get; private set; } = false;
|
public static bool ARDB_INITCHECK {get; private set; } = false;
|
||||||
@ -203,47 +200,55 @@ namespace ArmaRAMDb
|
|||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "get":
|
case "get":
|
||||||
HandleGetOperation(_id, args, argc);
|
HandleGetOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_get\",{args[0]}]");
|
WriteOutput(output, $"[\"{_id}_get\",{args[0]}]");
|
||||||
return 100;
|
return 100;
|
||||||
case "hdel":
|
case "hdel":
|
||||||
HandleHDelOperation(args, argc);
|
HandleHashDeleteOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "hdelid":
|
case "hdelid":
|
||||||
HandleHDelIdOperation(args, argc);
|
HandleHashDeleteIdOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "hget":
|
case "hget":
|
||||||
HandleHGetOperation(_id, args, argc);
|
HandleHashGetOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_hget\",{args[1]}]");
|
WriteOutput(output, $"[\"{_id}_hget\",{args[1]}]");
|
||||||
return 100;
|
return 100;
|
||||||
case "hgetid":
|
case "hgetid":
|
||||||
HandleHGetIdOperation(_id, args, argc);
|
HandleHashGetIdOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_hgetid\",{args[0]}]");
|
WriteOutput(output, $"[\"{_id}_hgetid\",{args[0]}]");
|
||||||
return 100;
|
return 100;
|
||||||
case "hgetall":
|
case "hgetall":
|
||||||
HandleHGetAllOperation(_id, args, argc);
|
HandleHashGetAllOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_hgetall\",{args[0]}]");
|
WriteOutput(output, $"[\"{_id}_hgetall\",{args[0]}]");
|
||||||
return 100;
|
return 100;
|
||||||
case "hgetallid":
|
case "hgetallid":
|
||||||
HandleHGetAllIdOperation(_id, args, argc);
|
HandleHashGetAllIdOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_hgetallid\",{args[0]}]");
|
WriteOutput(output, $"[\"{_id}_hgetallid\",{args[0]}]");
|
||||||
return 100;
|
return 100;
|
||||||
case "hrem":
|
case "hrem":
|
||||||
HandleHRemOperation(args, argc);
|
HandleHashRemoveOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "hremid":
|
case "hremid":
|
||||||
HandleHRemIdOperation(args, argc);
|
HandleHashRemoveIdOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "hset":
|
case "hset":
|
||||||
HandleHSetOperation(args, argc);
|
HandleHashSetOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "hsetid":
|
case "hsetid":
|
||||||
HandleHSetIdOperation(args, argc);
|
HandleHashSetIdOperation(args, argc);
|
||||||
|
WriteOutput(output, "Async");
|
||||||
|
return 200;
|
||||||
|
case "hsetbulk":
|
||||||
|
HandleHashSetBulkOperation(args, argc);
|
||||||
|
WriteOutput(output, "Async");
|
||||||
|
return 200;
|
||||||
|
case "hsetbulkid":
|
||||||
|
HandleHashSetBulkIdOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
case "isloaded":
|
case "isloaded":
|
||||||
@ -253,18 +258,22 @@ namespace ArmaRAMDb
|
|||||||
HandleListAddOperation(args, argc);
|
HandleListAddOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
return 200;
|
return 200;
|
||||||
|
case "listdel":
|
||||||
|
HandleListDeleteOperation(args, argc);
|
||||||
|
WriteOutput(output, "Async");
|
||||||
|
return 200;
|
||||||
case "listidx":
|
case "listidx":
|
||||||
HandleListIdxOperation(_id, args, argc);
|
HandleListIndexOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_listindex\",{args[0]}]");
|
WriteOutput(output, $"[\"{_id}_listindex\",{args[0]}]");
|
||||||
return 100;
|
return 100;
|
||||||
case "listrem":
|
|
||||||
HandleListRemOperation(args, argc);
|
|
||||||
WriteOutput(output, "Async");
|
|
||||||
return 200;
|
|
||||||
case "listrng":
|
case "listrng":
|
||||||
HandleListRngOperation(_id, args, argc);
|
HandleListRangeOperation(args, argc);
|
||||||
WriteOutput(output, $"[\"{_id}_listrange\",{args[0]}]");
|
WriteOutput(output, $"[\"{_id}_listrange\",{args[0]}]");
|
||||||
return 100;
|
return 100;
|
||||||
|
case "listrem":
|
||||||
|
HandleListRemoveOperation(args, argc);
|
||||||
|
WriteOutput(output, "Async");
|
||||||
|
return 200;
|
||||||
case "listset":
|
case "listset":
|
||||||
HandleListSetOperation(args, argc);
|
HandleListSetOperation(args, argc);
|
||||||
WriteOutput(output, "Async");
|
WriteOutput(output, "Async");
|
||||||
@ -285,7 +294,7 @@ namespace ArmaRAMDb
|
|||||||
WriteOutput(output, ARDB_VERSION);
|
WriteOutput(output, ARDB_VERSION);
|
||||||
return 100;
|
return 100;
|
||||||
default:
|
default:
|
||||||
WriteOutput(output, "Available functions: del, get, hdel, hdelid, hget, hgetid, hgetall, hgetallid, hrem, hremid, hset, hsetid, isloaded, listadd, listidx, listrem, listrng, listset, load, save, set, version");
|
WriteOutput(output, "Available functions: delete, get, hget, hgetid, hgetall, hgetallid, hset, hsetid, hsetbulk, hsetbulkid, isloaded, load, save, set, version");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,241 +352,226 @@ namespace ArmaRAMDb
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleHDelOperation(List<string> args, int argc)
|
private static void HandleHashDeleteOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
HashStore.HashDelete(STEAMID);
|
||||||
{
|
|
||||||
await HashStore.HashDelete(STEAMID);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleHDelIdOperation(List<string> args, int argc)
|
private static void HandleHashDeleteIdOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
HashStore.HashDelete(args[0]);
|
||||||
{
|
|
||||||
await HashStore.HashDelete(args[0].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HandleHGetOperation(long _id, List<string> args, int argc)
|
|
||||||
{
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
string _uniqueID = $"{_id}_hget";
|
|
||||||
if (argc == 2)
|
|
||||||
await HashStore.HashGet(STEAMID, args[0].Trim('"'), args[1].Trim('"'), _uniqueID);
|
|
||||||
if (argc == 3)
|
|
||||||
await HashStore.HashGet(STEAMID, args[0].Trim('"'), args[1].Trim('"'), _uniqueID, args[2].Trim('"'));
|
|
||||||
if (argc == 4)
|
|
||||||
await HashStore.HashGet(STEAMID, args[0].Trim('"'), args[1].Trim('"'), _uniqueID, args[2].Trim('"'), args[3].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HandleHGetIdOperation(long _id, List<string> args, int argc)
|
|
||||||
{
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
string _uniqueID = $"{_id}_hgetid";
|
|
||||||
if (argc == 3)
|
|
||||||
await HashStore.HashGet(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID);
|
|
||||||
if (argc == 4)
|
|
||||||
await HashStore.HashGet(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID, args[3].Trim('"'));
|
|
||||||
if (argc == 5)
|
|
||||||
await HashStore.HashGet(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID, args[3].Trim('"'), args[4].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HandleHGetAllOperation(long _id, List<string> args, int argc)
|
|
||||||
{
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
string _uniqueID = $"{_id}_hgetall";
|
|
||||||
if (argc == 1)
|
|
||||||
await HashStore.HashGetAllAsync(STEAMID, args[0].Trim('"'), _uniqueID);
|
|
||||||
if (argc == 2)
|
|
||||||
await HashStore.HashGetAllAsync(STEAMID, args[0].Trim('"'), _uniqueID, args[1].Trim('"'));
|
|
||||||
if (argc == 3)
|
|
||||||
await HashStore.HashGetAllAsync(STEAMID, args[0].Trim('"'), _uniqueID, args[1].Trim('"'), args[2].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HandleHGetAllIdOperation(long _id, List<string> args, int argc)
|
|
||||||
{
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
string _uniqueID = $"{_id}_hgetallid";
|
|
||||||
if (argc == 2)
|
|
||||||
await HashStore.HashGetAllAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID);
|
|
||||||
if (argc == 3)
|
|
||||||
await HashStore.HashGetAllAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID, args[2].Trim('"'));
|
|
||||||
if (argc == 4)
|
|
||||||
await HashStore.HashGetAllAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID, args[2], args[3].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleHRemOperation(List<string> args, int argc)
|
private static void HandleHashGetOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var value = HashStore.HashGet(STEAMID, args[0]);
|
||||||
{
|
|
||||||
await HashStore.HashRemoveAsync(STEAMID, args[0].Trim('"'));
|
Log($"HashGet: {SerializeList([value])}", "debug");
|
||||||
});
|
Callback("ArmaRAMDb", args[1].Trim('"'), SerializeList([value]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleHRemIdOperation(List<string> args, int argc)
|
private static void HandleHashGetIdOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var value = HashStore.HashGet(args[0], args[1]);
|
||||||
{
|
|
||||||
await HashStore.HashRemoveAsync(args[0].Trim('"'), args[1].Trim('"'));
|
Log($"HashGetId: {SerializeList([value])}", "debug");
|
||||||
});
|
Callback("ArmaRAMDb", args[2].Trim('"'), SerializeList([value]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleHSetOperation(List<string> args, int argc)
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashGetAllOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var contents = HashStore.HashGetAll(STEAMID);
|
||||||
{
|
var list = contents.SelectMany(kv => new[] { kv.Key, kv.Value }).ToList();
|
||||||
if (argc > 2)
|
|
||||||
{
|
Log($"HashGetAll: {SerializeList(list)}", "debug");
|
||||||
var bulkValues = new Dictionary<string, string>();
|
Callback("ArmaRAMDb", args[0].Trim('"'), SerializeList(list));
|
||||||
for (var i = 0; i < argc; i += 2)
|
|
||||||
{
|
|
||||||
bulkValues[args[i].Trim('"')] = args[i + 1];
|
|
||||||
}
|
|
||||||
await HashStore.HashSetBulkAsync(STEAMID, bulkValues);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await HashStore.HashSetAsync(STEAMID, args[0].Trim('"'), args[1].Trim('"'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleHSetIdOperation(List<string> args, int argc)
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashGetAllIdOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var hashId = args[0];
|
||||||
{
|
var contents = HashStore.HashGetAll(hashId);
|
||||||
if (argc > 4)
|
var list = contents.SelectMany(kv => new[] { kv.Key, kv.Value }).ToList();
|
||||||
{
|
|
||||||
var bulkValues = new Dictionary<string, string>();
|
Log($"HashGetAllId: {SerializeList(list)}", "debug");
|
||||||
for (var i = 1; i < argc; i += 2)
|
Callback("ArmaRAMDb", args[1].Trim('"'), SerializeList(list));
|
||||||
{
|
|
||||||
bulkValues[args[i].Trim('"')] = args[i + 1];
|
|
||||||
}
|
|
||||||
await HashStore.HashSetBulkAsync(args[0].Trim('"'), bulkValues);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await HashStore.HashSetAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashRemoveOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
HashStore.HashRemove(STEAMID, args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashRemoveIdOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
var value = HashStore.HashRemove(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashSetOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
Log($"HashSet: {SerializeList(args)}", "debug");
|
||||||
|
HashStore.HashSet(STEAMID, args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashSetIdOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
Log($"HashSetId: {SerializeList(args)}", "debug");
|
||||||
|
HashStore.HashSet(args[0], args[1], args[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashSetBulkOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
var values = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
for (int i = 0; i < args.Count; i += 2)
|
||||||
|
{
|
||||||
|
string key = args[i];
|
||||||
|
string value = args[i + 1];
|
||||||
|
values.Add(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log($"BulkHashSet: Keys={string.Join(",", values.Keys)}", "debug");
|
||||||
|
HashStore.HashSetBulk(STEAMID, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleHashSetBulkIdOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
var hashId = args[0];
|
||||||
|
var values = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
for (int i = 1; i < args.Count; i += 2)
|
||||||
|
{
|
||||||
|
string key = args[i];
|
||||||
|
string value = args[i + 1];
|
||||||
|
values.Add(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log($"BulkHashSetId: Keys={string.Join(",", values.Keys)}", "debug");
|
||||||
|
HashStore.HashSetBulk(hashId, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleListAddOperation(List<string> args, int argc)
|
private static void HandleListAddOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var key = args[0];
|
||||||
{
|
var value = args[1];
|
||||||
switch (argc)
|
|
||||||
{
|
Log($"ListAdd: {SerializeList([key, value])}", "debug");
|
||||||
case > 2:
|
ListStore.ListAdd(key, value);
|
||||||
for (var i = 0; i < argc; i++)
|
|
||||||
{
|
|
||||||
await ListStore.ListAddAsync(args[0].Trim('"'), args[i]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
await ListStore.ListAddAsync(args[0].Trim('"'), args[1].Trim('"'));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleListRemOperation(List<string> args, int argc)
|
private static void HandleListDeleteOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var listId = args[0];
|
||||||
{
|
|
||||||
await ListStore.ListSetAsync(args[0].Trim('"'), args[1].Trim('"'), "RAMDBREMOVE");
|
Log($"ListDelete: {SerializeList([listId])}", "debug");
|
||||||
await ListStore.ListRemoveAsync(args[0].Trim('"'), "RAMDBREMOVE");
|
ListStore.ListDelete(listId);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleListIdxOperation(long _id, List<string> args, int argc)
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleListIndexOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var listId = args[0];
|
||||||
{
|
var key = args[1];
|
||||||
string _uniqueID = $"{_id}_listidx";
|
var value = ListStore.ListIndex(listId, int.Parse(key));
|
||||||
if (argc == 3)
|
|
||||||
await ListStore.ListIndexAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID);
|
Log($"ListIndex: {SerializeList([key, value])}", "debug");
|
||||||
if (argc == 4)
|
Callback("ArmaRAMDb", args[2].Trim('"'), SerializeList([value]));
|
||||||
await ListStore.ListIndexAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID, args[3].Trim('"'));
|
|
||||||
if (argc == 5)
|
|
||||||
await ListStore.ListIndexAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID, args[3].Trim('"'), args[4].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleListRngOperation(long _id, List<string> args, int argc)
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleListRangeOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var listId = args[0];
|
||||||
{
|
var startIndex = int.Parse(args[1]);
|
||||||
string _uniqueID = $"{_id}_listrng";
|
var endIndex = int.Parse(args[2]);
|
||||||
if (argc == 4)
|
|
||||||
await ListStore.ListRangeAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), args[3].Trim('"'), _uniqueID);
|
var values = ListStore.ListRange(listId, startIndex, endIndex);
|
||||||
if (argc == 5)
|
|
||||||
await ListStore.ListRangeAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), args[3].Trim('"'), _uniqueID, args[4].Trim('"'));
|
Log($"ListRange: ListId={listId} Start={startIndex} End={endIndex} Values={SerializeList(values)}", "debug");
|
||||||
if (argc == 6)
|
Callback("ArmaRAMDb", args[3].Trim('"'), SerializeList(values));
|
||||||
await ListStore.ListRangeAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), args[3].Trim('"'), _uniqueID, args[4].Trim('"'), args[5].Trim('"'));
|
}
|
||||||
});
|
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleListRemoveOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
|
{
|
||||||
|
var listId = args[0];
|
||||||
|
var index = int.Parse(args[1]);
|
||||||
|
|
||||||
|
ListStore.ListSet(listId, index, "RAMDBREMOVE");
|
||||||
|
ListStore.ListRemove(listId, "RAMDBREMOVE");
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleListSetOperation(List<string> args, int argc)
|
private static void HandleListSetOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var listId = args[0];
|
||||||
{
|
var index = int.Parse(args[1]);
|
||||||
await ListStore.ListSetAsync(args[0].Trim('"'), args[1].Trim('"'), args[2]);
|
var value = args[2];
|
||||||
});
|
|
||||||
|
ListStore.ListSet(listId, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleSetOperation(List<string> args, int argc)
|
private static void HandleSetOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var key = args[0];
|
||||||
{
|
var value = args[1];
|
||||||
await KeyValueStore.SetAsync(args[0].Trim('"'), args[1]);
|
|
||||||
});
|
KeyValueStore.SetValue(key, value);
|
||||||
|
Log($"Set: Key={key} Value={value}", "debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleGetOperation(long _id, List<string> args, int argc)
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
private static void HandleGetOperation(List<string> args, int argc)
|
||||||
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var key = args[0];
|
||||||
{
|
var value = KeyValueStore.GetValue(key);
|
||||||
string _uniqueID = $"{_id}_get";
|
|
||||||
if (argc == 2)
|
Log($"Get: Key={key} Value={value}", "debug");
|
||||||
await KeyValueStore.GetAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID);
|
Callback("ArmaRAMDb", args[1].Trim('"'), SerializeList([value]));
|
||||||
if (argc == 3)
|
|
||||||
await KeyValueStore.GetAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID, args[2].Trim('"'));
|
|
||||||
if (argc == 4)
|
|
||||||
await KeyValueStore.GetAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID, args[2].Trim('"'), args[3].Trim('"'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060 // Remove unused parameter
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
private static void HandleDeleteOperation(List<string> args, int argc)
|
private static void HandleDeleteOperation(List<string> args, int argc)
|
||||||
#pragma warning restore IDE0060 // Remove unused parameter
|
#pragma warning restore IDE0060 // Remove unused parameter
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
var key = args[0];
|
||||||
{
|
|
||||||
await KeyValueStore.DeleteAsync(args[0].Trim('"'));
|
KeyValueStore.DeleteValue(key);
|
||||||
});
|
Log($"Delete: Key={key}", "debug");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,7 @@
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace ArmaRAMDb
|
namespace ArmaRAMDb
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
{
|
||||||
internal class RAMDb(string path = RAMDb.DEFAULT_STORAGE_PATH) : IDisposable
|
internal class RAMDb(string path = RAMDb.DEFAULT_STORAGE_PATH) : IDisposable
|
||||||
{
|
{
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace ArmaRAMDb
|
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
|
||||||
internal class Utils
|
|
||||||
{
|
|
||||||
public static string Base64Decode(string encodedString)
|
|
||||||
{
|
|
||||||
byte[] data = Convert.FromBase64String(encodedString);
|
|
||||||
return Encoding.UTF8.GetString(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string Base64Encode(string plainText)
|
|
||||||
{
|
|
||||||
byte[] data = Encoding.UTF8.GetBytes(plainText);
|
|
||||||
return Convert.ToBase64String(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string BuildArray(string text)
|
|
||||||
{
|
|
||||||
string str = $"[\"{text}\"]";
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<string> SplitIntoChunks(string data, int chunkSize)
|
|
||||||
{
|
|
||||||
int chunksNeeded = (int)Math.Ceiling((double)data.Length / chunkSize);
|
|
||||||
List<string> chunks = [];
|
|
||||||
|
|
||||||
for (int i = 0; i < chunksNeeded; i++)
|
|
||||||
{
|
|
||||||
int start = i * chunkSize;
|
|
||||||
int end = Math.Min(data.Length, start + chunkSize);
|
|
||||||
chunks.Add(data[start..end]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return chunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void CheckByteCount(string uniqueId, string data, string function, string entity, bool call, int bufferSize)
|
|
||||||
{
|
|
||||||
if (Encoding.UTF8.GetByteCount(data) <= bufferSize)
|
|
||||||
{
|
|
||||||
if (!data.StartsWith('['))
|
|
||||||
data = BuildArray(data);
|
|
||||||
Main.Log($"{data}", "debug");
|
|
||||||
|
|
||||||
string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call},{data},\"{entity}\"]";
|
|
||||||
Main.Log($"{dataAsString}", "debug");
|
|
||||||
Main.Callback("ArmaRAMDb", "ramdb_db_fnc_handler", dataAsString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!data.StartsWith('['))
|
|
||||||
data = BuildArray(data);
|
|
||||||
Main.Log($"{data}", "debug");
|
|
||||||
var chunks = SplitIntoChunks(data, bufferSize);
|
|
||||||
int totalChunks = chunks.Count;
|
|
||||||
|
|
||||||
foreach (string chunk in chunks)
|
|
||||||
{
|
|
||||||
string chunkAsString = $"[{uniqueId},{function},{chunks.IndexOf(chunk)},{totalChunks},\"{chunk}\",{call},\"{entity}\"]";
|
|
||||||
Main.Callback("ArmaRAMDb", "ramdb_db_fnc_fetch", chunkAsString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user