Major Update 01012025@1335
This commit is contained in:
parent
f74d0f3191
commit
595540350a
Binary file not shown.
BIN
ArmaRAMDb_x64.so
BIN
ArmaRAMDb_x64.so
Binary file not shown.
48
addons/db/functions/fnc_addTask.sqf
Normal file
48
addons/db/functions/fnc_addTask.sqf
Normal file
@ -0,0 +1,48 @@
|
||||
#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); };
|
35
addons/db/functions/fnc_delete.sqf
Normal file
35
addons/db/functions/fnc_delete.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
#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]];
|
66
addons/db/functions/fnc_fetch.sqf
Normal file
66
addons/db/functions/fnc_fetch.sqf
Normal file
@ -0,0 +1,66 @@
|
||||
#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])};
|
||||
};
|
49
addons/db/functions/fnc_get.sqf
Normal file
49
addons/db/functions/fnc_get.sqf
Normal file
@ -0,0 +1,49 @@
|
||||
#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);
|
||||
};
|
47
addons/db/functions/fnc_handler.sqf
Normal file
47
addons/db/functions/fnc_handler.sqf
Normal file
@ -0,0 +1,47 @@
|
||||
#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; };
|
||||
};
|
49
addons/db/functions/fnc_hashGet.sqf
Normal file
49
addons/db/functions/fnc_hashGet.sqf
Normal file
@ -0,0 +1,49 @@
|
||||
#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);
|
||||
};
|
48
addons/db/functions/fnc_hashGetAll.sqf
Normal file
48
addons/db/functions/fnc_hashGetAll.sqf
Normal file
@ -0,0 +1,48 @@
|
||||
#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);
|
||||
};
|
49
addons/db/functions/fnc_hashGetAllId.sqf
Normal file
49
addons/db/functions/fnc_hashGetAllId.sqf
Normal file
@ -0,0 +1,49 @@
|
||||
#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);
|
||||
};
|
50
addons/db/functions/fnc_hashGetId.sqf
Normal file
50
addons/db/functions/fnc_hashGetId.sqf
Normal file
@ -0,0 +1,50 @@
|
||||
#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);
|
||||
};
|
36
addons/db/functions/fnc_hashSet.sqf
Normal file
36
addons/db/functions/fnc_hashSet.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
#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]];
|
35
addons/db/functions/fnc_hashSetBulk.sqf
Normal file
35
addons/db/functions/fnc_hashSetBulk.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
#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];
|
37
addons/db/functions/fnc_hashSetId.sqf
Normal file
37
addons/db/functions/fnc_hashSetId.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
#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]];
|
35
addons/db/functions/fnc_hashSetIdBulk.sqf
Normal file
35
addons/db/functions/fnc_hashSetIdBulk.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
#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];
|
37
addons/db/functions/fnc_init.sqf
Normal file
37
addons/db/functions/fnc_init.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
#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!";
|
36
addons/db/functions/fnc_listAdd.sqf
Normal file
36
addons/db/functions/fnc_listAdd.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
#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]];
|
50
addons/db/functions/fnc_listGet.sqf
Normal file
50
addons/db/functions/fnc_listGet.sqf
Normal file
@ -0,0 +1,50 @@
|
||||
#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);
|
||||
};
|
49
addons/db/functions/fnc_listLoad.sqf
Normal file
49
addons/db/functions/fnc_listLoad.sqf
Normal file
@ -0,0 +1,49 @@
|
||||
#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);
|
||||
};
|
36
addons/db/functions/fnc_listRemove.sqf
Normal file
36
addons/db/functions/fnc_listRemove.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
#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]];
|
37
addons/db/functions/fnc_listSet.sqf
Normal file
37
addons/db/functions/fnc_listSet.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
#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]];
|
3
addons/db/functions/fnc_printAddonName.sqf
Normal file
3
addons/db/functions/fnc_printAddonName.sqf
Normal file
@ -0,0 +1,3 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
systemChat format ["Thank you for using the %1", 'ADDON'];
|
69
addons/db/functions/fnc_processQueue.sqf
Normal file
69
addons/db/functions/fnc_processQueue.sqf
Normal file
@ -0,0 +1,69 @@
|
||||
#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;
|
31
addons/db/functions/fnc_save.sqf
Normal file
31
addons/db/functions/fnc_save.sqf
Normal file
@ -0,0 +1,31 @@
|
||||
#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", []];
|
48
addons/db/functions/fnc_scheduler.sqf
Normal file
48
addons/db/functions/fnc_scheduler.sqf
Normal file
@ -0,0 +1,48 @@
|
||||
#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;
|
36
addons/db/functions/fnc_set.sqf
Normal file
36
addons/db/functions/fnc_set.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
#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]];
|
34
addons/db/functions/fnc_test.sqf
Normal file
34
addons/db/functions/fnc_test.sqf
Normal file
@ -0,0 +1,34 @@
|
||||
#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
addons/db/functions/script_component.hpp
Normal file
1
addons/db/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "..\script_component.hpp"
|
Binary file not shown.
Binary file not shown.
@ -1,37 +1,57 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
||||
namespace ArmaRAMDb
|
||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
||||
{
|
||||
internal class HashStore
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, string>> _hashTables = RAMDb._hashTables;
|
||||
|
||||
public static bool HashDelete(string tableName)
|
||||
public static async Task HashDelete(string tableName)
|
||||
{
|
||||
var result = _hashTables.TryRemove(tableName, out _);
|
||||
await Task.Yield();
|
||||
bool result = _hashTables.TryRemove(tableName, out _);
|
||||
|
||||
Main.Log($"HashDelete: {tableName} - Success: {result}", "debug");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string HashGet(string tableName, string key)
|
||||
public static async Task HashGet(string tableName, string key, string function, string uniqueID, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
||||
{
|
||||
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))
|
||||
{
|
||||
string data = table.TryGetValue(key, out string value) ? value : string.Empty;
|
||||
Main.Log($"HashGet: {tableName} - {key}", "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");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> HashGetAll(string tableName)
|
||||
public static async Task HashGetAllAsync(string tableName, string function, string uniqueId, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
||||
{
|
||||
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))
|
||||
{
|
||||
var contents = table.ToDictionary(kv => kv.Key, kv => kv.Value);
|
||||
@ -42,45 +62,53 @@ namespace ArmaRAMDb
|
||||
Main.Log($"Key: {entry.Key}, Value: {entry.Value}", "debug");
|
||||
}
|
||||
|
||||
return contents;
|
||||
string data = string.Join(",", contents.Select(kv => $"[\"{kv.Key}\",{kv.Value}]"));
|
||||
Utils.CheckByteCount(uniqueId, $"[{data}]", function, entity, Convert.ToBoolean(call), bufferSize);
|
||||
}
|
||||
|
||||
Main.Log($"Table {tableName} not found", "debug");
|
||||
return [];
|
||||
}
|
||||
|
||||
public static bool HashRemove(string tableName, string key)
|
||||
else
|
||||
{
|
||||
Main.Log($"Table {tableName} not found", "debug");
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task HashRemoveAsync(string tableName, string key)
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
if (_hashTables.TryGetValue(tableName, out var table))
|
||||
{
|
||||
var result = table.TryRemove(key, out _);
|
||||
Main.Log($"HashRemove: {tableName} - {key} - Success: {result}", "debug");
|
||||
return result;
|
||||
table.TryRemove(key, out _);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.Log($"Table not found: {tableName}", "debug");
|
||||
}
|
||||
}
|
||||
|
||||
Main.Log($"Table {tableName} or Key {key} not found", "debug");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HashSet(string tableName, string key, string value)
|
||||
public static async Task HashSetBulkAsync(string tableName, Dictionary<string, string> values)
|
||||
{
|
||||
var table = _hashTables.GetOrAdd(tableName, _ => new ConcurrentDictionary<string, string>());
|
||||
table.AddOrUpdate(key, value, (_, _) => value);
|
||||
|
||||
Main.Log($"HashSet: {tableName} - {key} - {value}", "debug");
|
||||
return true;
|
||||
}
|
||||
await Task.Yield();
|
||||
|
||||
public static bool HashSetBulk(string tableName, Dictionary<string, string> values)
|
||||
{
|
||||
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");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
public static async Task HashSetAsync(string tableName, string key, string value)
|
||||
{
|
||||
await HashSetBulkAsync(tableName, new Dictionary<string, string> { { key, value } });
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +1,50 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
||||
namespace ArmaRAMDb
|
||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
||||
{
|
||||
internal class KeyValueStore
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, string> _keyValues = RAMDb._keyValues;
|
||||
|
||||
public static string GetValue(string key)
|
||||
public static async Task GetAsync(string key, string function, string uniqueId, string entity = null, string call = "false", int buffersize = Main.ARDB_BUFFERSIZE)
|
||||
{
|
||||
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;
|
||||
|
||||
Main.Log($"GetValue: {key} - Value: {value}", "debug");
|
||||
return value;
|
||||
|
||||
Utils.CheckByteCount(uniqueId, value, function, entity, Convert.ToBoolean(call), buffersize);
|
||||
}
|
||||
|
||||
public static bool DeleteValue(string key)
|
||||
public static async Task SetAsync(string key, string value)
|
||||
{
|
||||
var result = _keyValues.TryRemove(key, out _);
|
||||
await Task.Yield();
|
||||
|
||||
Main.Log($"DeleteValue: {key} - Success: {result}", "debug");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool SetValue(string key, string value)
|
||||
if (value.StartsWith('[') && value.EndsWith(']'))
|
||||
{
|
||||
_keyValues.AddOrUpdate(key, value, (_, _) => value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_keyValues.AddOrUpdate(key, $"[\"{value}\"]", (_, _) => $"[\"{value}\"]");
|
||||
}
|
||||
|
||||
Main.Log($"SetValue: {key} - Value: {value}", "debug");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static async Task DeleteAsync(string key)
|
||||
{
|
||||
await Task.Yield();
|
||||
var result = _keyValues.TryRemove(key, out _);
|
||||
Main.Log($"DeleteValue: {key} - Success: {result}", "debug");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,107 +1,118 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
||||
namespace ArmaRAMDb
|
||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
||||
{
|
||||
internal class ListStore
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, List<string>> _lists = RAMDb._lists;
|
||||
|
||||
public static bool ListAdd(string listName, string value)
|
||||
public static async Task ListAddAsync(string listName, string value)
|
||||
{
|
||||
if (_lists.TryGetValue(listName, out var list))
|
||||
await Task.Yield();
|
||||
|
||||
lock (_lists)
|
||||
{
|
||||
if (!_lists.TryGetValue(listName, out List<string> list))
|
||||
{
|
||||
list = [];
|
||||
_lists[listName] = list;
|
||||
}
|
||||
|
||||
lock (list)
|
||||
{
|
||||
if (value.StartsWith('[') && value.EndsWith(']'))
|
||||
{
|
||||
list.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add($"[\"{value}\"]");
|
||||
}
|
||||
Main.Log($"ListAdd: {listName} - Value: {value}", "debug");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Main.Log($"List not found: {listName}", "debug");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ListDelete(string listName)
|
||||
public static async Task ListIndexAsync(string listName, string index, string function, string uniqueId, string entity = null, string call = "false", int bufferSize = Main.ARDB_BUFFERSIZE)
|
||||
{
|
||||
var result = _lists.TryRemove(listName, out _);
|
||||
await Task.Yield();
|
||||
|
||||
Main.Log($"ListDelete: {listName} - Success: {result}", "debug");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string ListIndex(string listName, int index)
|
||||
{
|
||||
if (_lists.TryGetValue(listName, out var list))
|
||||
{
|
||||
lock (list)
|
||||
{
|
||||
string value = index >= 0 && index < list.Count ? list[index] : string.Empty;
|
||||
Main.Log($"ListIndex: {listName} - Index: {index} - Value: {value}", "debug");
|
||||
return value;
|
||||
int idx = int.Parse(index);
|
||||
string value = idx >= 0 && idx < list.Count ? list[idx] : string.Empty;
|
||||
Main.Log($"ListIndex: {listName} - Index: {idx} - Value: {value}", "debug");
|
||||
Utils.CheckByteCount(uniqueId, value, function, entity, Convert.ToBoolean(call), bufferSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Main.Log($"List not found: {listName}", "debug");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static List<string> ListRange(string listName, int startIndex, int endIndex)
|
||||
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)
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
if (_lists.TryGetValue(listName, out var list))
|
||||
{
|
||||
lock (list)
|
||||
{
|
||||
startIndex = Math.Max(0, startIndex);
|
||||
endIndex = Math.Min(list.Count - 1, endIndex);
|
||||
int start = int.Parse(startIndex);
|
||||
int end = int.Parse(endIndex);
|
||||
start = Math.Max(0, start);
|
||||
end = Math.Min(list.Count - 1, end);
|
||||
|
||||
if (startIndex <= endIndex)
|
||||
if (start <= end)
|
||||
{
|
||||
int count = endIndex - startIndex + 1;
|
||||
var value = list.GetRange(startIndex, count);
|
||||
Main.Log($"ListRange: {listName} - StartIndex: {startIndex} - EndIndex: {endIndex} - Count: {count}", "debug");
|
||||
return value;
|
||||
int count = end - start + 1;
|
||||
var value = list.GetRange(start, count);
|
||||
string data = string.Join(",", value);
|
||||
Main.Log($"ListRange: {listName} - StartIndex: {start} - EndIndex: {end} - Count: {count}", "debug");
|
||||
Utils.CheckByteCount(uniqueId, $"[{data}]", function, entity, Convert.ToBoolean(call), bufferSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Main.Log($"List not found: {listName}", "debug");
|
||||
return [];
|
||||
}
|
||||
|
||||
public static bool ListRemove(string listName, string value)
|
||||
public static async Task ListSetAsync(string listName, string index, 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))
|
||||
{
|
||||
lock (list)
|
||||
{
|
||||
int removedCount = list.RemoveAll(item => item == value);
|
||||
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,7 +2,9 @@
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
||||
namespace ArmaRAMDb
|
||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
||||
{
|
||||
public class CallContext
|
||||
{
|
||||
@ -16,6 +18,7 @@ namespace ArmaRAMDb
|
||||
public class Main
|
||||
{
|
||||
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 bool ARDB_DEBUG {get; private set; } = false;
|
||||
public static bool ARDB_INITCHECK {get; private set; } = false;
|
||||
@ -200,55 +203,47 @@ namespace ArmaRAMDb
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "get":
|
||||
HandleGetOperation(args, argc);
|
||||
HandleGetOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_get\",{args[0]}]");
|
||||
return 100;
|
||||
case "hdel":
|
||||
HandleHashDeleteOperation(args, argc);
|
||||
HandleHDelOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hdelid":
|
||||
HandleHashDeleteIdOperation(args, argc);
|
||||
HandleHDelIdOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hget":
|
||||
HandleHashGetOperation(args, argc);
|
||||
HandleHGetOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_hget\",{args[1]}]");
|
||||
return 100;
|
||||
case "hgetid":
|
||||
HandleHashGetIdOperation(args, argc);
|
||||
HandleHGetIdOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_hgetid\",{args[0]}]");
|
||||
return 100;
|
||||
case "hgetall":
|
||||
HandleHashGetAllOperation(args, argc);
|
||||
HandleHGetAllOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_hgetall\",{args[0]}]");
|
||||
return 100;
|
||||
case "hgetallid":
|
||||
HandleHashGetAllIdOperation(args, argc);
|
||||
HandleHGetAllIdOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_hgetallid\",{args[0]}]");
|
||||
return 100;
|
||||
case "hrem":
|
||||
HandleHashRemoveOperation(args, argc);
|
||||
HandleHRemOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hremid":
|
||||
HandleHashRemoveIdOperation(args, argc);
|
||||
HandleHRemIdOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hset":
|
||||
HandleHashSetOperation(args, argc);
|
||||
HandleHSetOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hsetid":
|
||||
HandleHashSetIdOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hsetbulk":
|
||||
HandleHashSetBulkOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "hsetbulkid":
|
||||
HandleHashSetBulkIdOperation(args, argc);
|
||||
HandleHSetIdOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "isloaded":
|
||||
@ -258,22 +253,18 @@ namespace ArmaRAMDb
|
||||
HandleListAddOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "listdel":
|
||||
HandleListDeleteOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "listidx":
|
||||
HandleListIndexOperation(args, argc);
|
||||
HandleListIdxOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_listindex\",{args[0]}]");
|
||||
return 100;
|
||||
case "listrng":
|
||||
HandleListRangeOperation(args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_listrange\",{args[0]}]");
|
||||
return 100;
|
||||
case "listrem":
|
||||
HandleListRemoveOperation(args, argc);
|
||||
HandleListRemOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
return 200;
|
||||
case "listrng":
|
||||
HandleListRngOperation(_id, args, argc);
|
||||
WriteOutput(output, $"[\"{_id}_listrange\",{args[0]}]");
|
||||
return 100;
|
||||
case "listset":
|
||||
HandleListSetOperation(args, argc);
|
||||
WriteOutput(output, "Async");
|
||||
@ -294,7 +285,7 @@ namespace ArmaRAMDb
|
||||
WriteOutput(output, ARDB_VERSION);
|
||||
return 100;
|
||||
default:
|
||||
WriteOutput(output, "Available functions: delete, get, hget, hgetid, hgetall, hgetallid, hset, hsetid, hsetbulk, hsetbulkid, isloaded, load, save, set, version");
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -352,226 +343,241 @@ namespace ArmaRAMDb
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashDeleteOperation(List<string> args, int argc)
|
||||
private static void HandleHDelOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
HashStore.HashDelete(STEAMID);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await HashStore.HashDelete(STEAMID);
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashDeleteIdOperation(List<string> args, int argc)
|
||||
private static void HandleHDelIdOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
HashStore.HashDelete(args[0]);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
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
|
||||
private static void HandleHashGetOperation(List<string> args, int argc)
|
||||
private static void HandleHRemOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var value = HashStore.HashGet(STEAMID, args[0]);
|
||||
|
||||
Log($"HashGet: {SerializeList([value])}", "debug");
|
||||
Callback("ArmaRAMDb", args[1].Trim('"'), SerializeList([value]));
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await HashStore.HashRemoveAsync(STEAMID, args[0].Trim('"'));
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashGetIdOperation(List<string> args, int argc)
|
||||
private static void HandleHRemIdOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var value = HashStore.HashGet(args[0], args[1]);
|
||||
|
||||
Log($"HashGetId: {SerializeList([value])}", "debug");
|
||||
Callback("ArmaRAMDb", args[2].Trim('"'), SerializeList([value]));
|
||||
}
|
||||
|
||||
#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();
|
||||
|
||||
Log($"HashGetAll: {SerializeList(list)}", "debug");
|
||||
Callback("ArmaRAMDb", args[0].Trim('"'), SerializeList(list));
|
||||
await HashStore.HashRemoveAsync(args[0].Trim('"'), args[1].Trim('"'));
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashGetAllIdOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
private static void HandleHSetOperation(List<string> args, int argc)
|
||||
{
|
||||
var hashId = args[0];
|
||||
var contents = HashStore.HashGetAll(hashId);
|
||||
var list = contents.SelectMany(kv => new[] { kv.Key, kv.Value }).ToList();
|
||||
|
||||
Log($"HashGetAllId: {SerializeList(list)}", "debug");
|
||||
Callback("ArmaRAMDb", args[1].Trim('"'), SerializeList(list));
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashRemoveOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
Task.Run(async () =>
|
||||
{
|
||||
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
|
||||
if (argc > 2)
|
||||
{
|
||||
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
|
||||
var bulkValues = new Dictionary<string, string>();
|
||||
for (var i = 0; i < argc; i += 2)
|
||||
{
|
||||
Log($"HashSet: {SerializeList(args)}", "debug");
|
||||
HashStore.HashSet(STEAMID, args[0], args[1]);
|
||||
bulkValues[args[i].Trim('"')] = args[i + 1];
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashSetIdOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
await HashStore.HashSetBulkAsync(STEAMID, bulkValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log($"HashSetId: {SerializeList(args)}", "debug");
|
||||
HashStore.HashSet(args[0], args[1], args[2]);
|
||||
await HashStore.HashSetAsync(STEAMID, args[0].Trim('"'), args[1].Trim('"'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleHashSetBulkOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
private static void HandleHSetIdOperation(List<string> args, int argc)
|
||||
{
|
||||
var values = new Dictionary<string, string>();
|
||||
|
||||
for (int i = 0; i < args.Count; i += 2)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
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
|
||||
if (argc > 4)
|
||||
{
|
||||
var hashId = args[0];
|
||||
var values = new Dictionary<string, string>();
|
||||
|
||||
for (int i = 1; i < args.Count; i += 2)
|
||||
var bulkValues = new Dictionary<string, string>();
|
||||
for (var i = 1; i < argc; i += 2)
|
||||
{
|
||||
string key = args[i];
|
||||
string value = args[i + 1];
|
||||
values.Add(key, value);
|
||||
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('"'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var key = args[0];
|
||||
var value = args[1];
|
||||
|
||||
Log($"ListAdd: {SerializeList([key, value])}", "debug");
|
||||
ListStore.ListAdd(key, value);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
switch (argc)
|
||||
{
|
||||
case > 2:
|
||||
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
|
||||
private static void HandleListDeleteOperation(List<string> args, int argc)
|
||||
private static void HandleListRemOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var listId = args[0];
|
||||
|
||||
Log($"ListDelete: {SerializeList([listId])}", "debug");
|
||||
ListStore.ListDelete(listId);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await ListStore.ListSetAsync(args[0].Trim('"'), args[1].Trim('"'), "RAMDBREMOVE");
|
||||
await ListStore.ListRemoveAsync(args[0].Trim('"'), "RAMDBREMOVE");
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleListIndexOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
private static void HandleListIdxOperation(long _id, List<string> args, int argc)
|
||||
{
|
||||
var listId = args[0];
|
||||
var key = args[1];
|
||||
var value = ListStore.ListIndex(listId, int.Parse(key));
|
||||
|
||||
Log($"ListIndex: {SerializeList([key, value])}", "debug");
|
||||
Callback("ArmaRAMDb", args[2].Trim('"'), SerializeList([value]));
|
||||
Task.Run(async () =>
|
||||
{
|
||||
string _uniqueID = $"{_id}_listidx";
|
||||
if (argc == 3)
|
||||
await ListStore.ListIndexAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), _uniqueID);
|
||||
if (argc == 4)
|
||||
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('"'));
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleListRangeOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
private static void HandleListRngOperation(long _id, List<string> args, int argc)
|
||||
{
|
||||
var listId = args[0];
|
||||
var startIndex = int.Parse(args[1]);
|
||||
var endIndex = int.Parse(args[2]);
|
||||
|
||||
var values = ListStore.ListRange(listId, startIndex, endIndex);
|
||||
|
||||
Log($"ListRange: ListId={listId} Start={startIndex} End={endIndex} Values={SerializeList(values)}", "debug");
|
||||
Callback("ArmaRAMDb", args[3].Trim('"'), SerializeList(values));
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleListRemoveOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var listId = args[0];
|
||||
var index = int.Parse(args[1]);
|
||||
|
||||
ListStore.ListSet(listId, index, "RAMDBREMOVE");
|
||||
ListStore.ListRemove(listId, "RAMDBREMOVE");
|
||||
string _uniqueID = $"{_id}_listrng";
|
||||
if (argc == 4)
|
||||
await ListStore.ListRangeAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), args[3].Trim('"'), _uniqueID);
|
||||
if (argc == 5)
|
||||
await ListStore.ListRangeAsync(args[0].Trim('"'), args[1].Trim('"'), args[2].Trim('"'), args[3].Trim('"'), _uniqueID, args[4].Trim('"'));
|
||||
if (argc == 6)
|
||||
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 HandleListSetOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var listId = args[0];
|
||||
var index = int.Parse(args[1]);
|
||||
var value = args[2];
|
||||
|
||||
ListStore.ListSet(listId, index, value);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await ListStore.ListSetAsync(args[0].Trim('"'), args[1].Trim('"'), args[2]);
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleSetOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var key = args[0];
|
||||
var value = args[1];
|
||||
|
||||
KeyValueStore.SetValue(key, value);
|
||||
Log($"Set: Key={key} Value={value}", "debug");
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await KeyValueStore.SetAsync(args[0].Trim('"'), args[1]);
|
||||
});
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
private static void HandleGetOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
private static void HandleGetOperation(long _id, List<string> args, int argc)
|
||||
{
|
||||
var key = args[0];
|
||||
var value = KeyValueStore.GetValue(key);
|
||||
|
||||
Log($"Get: Key={key} Value={value}", "debug");
|
||||
Callback("ArmaRAMDb", args[1].Trim('"'), SerializeList([value]));
|
||||
Task.Run(async () =>
|
||||
{
|
||||
string _uniqueID = $"{_id}_get";
|
||||
if (argc == 2)
|
||||
await KeyValueStore.GetAsync(args[0].Trim('"'), args[1].Trim('"'), _uniqueID);
|
||||
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
|
||||
private static void HandleDeleteOperation(List<string> args, int argc)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
var key = args[0];
|
||||
|
||||
KeyValueStore.DeleteValue(key);
|
||||
Log($"Delete: Key={key}", "debug");
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await KeyValueStore.DeleteAsync(args[0].Trim('"'));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
||||
namespace ArmaRAMDb
|
||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
||||
{
|
||||
internal class RAMDb(string path = RAMDb.DEFAULT_STORAGE_PATH) : IDisposable
|
||||
{
|
||||
|
70
extension/src/Utils.cs
Normal file
70
extension/src/Utils.cs
Normal file
@ -0,0 +1,70 @@
|
||||
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