Skip to content

Commit 9456822

Browse files
committed
Fix redis update, add redis docs, fix mongodb docs
1 parent 307ff4b commit 9456822

File tree

5 files changed

+73
-3
lines changed

5 files changed

+73
-3
lines changed

README.mkd

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ We created this database connection system because, even though there are good s
1212
- [Discord Logs for relevant information.](docs/features/DiscordLogs.mkd)
1313
- [ORM(Object Relation Mapping) support](docs/features/ORM.mkd)
1414
- [Script auto updater](docs/features/ScriptUpdater.mkd)
15+
- [Redis Support](docs/features/Redis.mkd)
1516
- [Logs system](docs/features/LogsSystem.mkd)
1617
- [Basic system to give a solution for each error](docs/features/BasicErrorSystem.mkd)
1718
- [Support Lua, JS, C# library](docs/features/SupportLuaJS.mkd)

docs/assets/Redis_Logo.png

116 KB
Loading

docs/features/MongoDB.mkd

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
We've added the support to Mongo DB, so you can use it as a database, you can mix it with other SQL & non-SQL databases. The multi-database support is a feature that you can use in SQL & non-SQL databases.
66

77
### Use
8-
To use is the same as the other databases, you just need to change the functions name and enable this option in the config.js ```Config.MongoDB``` and the database will be connected automatically on the server start.
8+
To use is the same as the other databases, you just need to enable this option in the config.js ```Config.MongoDB``` and provide the credentials in the server.cfg like this:
9+
```cfg
10+
set mongoCredentials_1 "mongodb://localhost:27017/test"
11+
```
12+
As you can see is the same structure like mysql you have to specify the id of the database because we've provided multiple database support here, then the database will be connected automatically on the server start.
13+
**Function list:**
914
```lua
1015
Mongo.MongoInsert(dbID, options, callback);
1116
Mongo.MongoFind(dbID, options, callback);

docs/features/Redis.mkd

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Redis Support
2+
<img src="../assets/Redis_Logo.png" width=250>
3+
4+
### Description
5+
We've added the support for Redis, this is a database that works with key-value, it's very fast and it's used for cache, we've added the support for this database because it's very useful for some things like save in memory data that need to be accessed very fast.
6+
7+
### Use
8+
To use this feature you need to enable the ```Config.Redis``` option in the ```config.js``` file, then you have to provide the redis credentials in the server.cfg file like this:
9+
```cfg
10+
set redisCredentials "redis://user:[email protected]:6379/0"
11+
```
12+
When the server start if the credentials are correct the resource will connect to the database and it will be ready to use.
13+
**Functions List:**
14+
15+
```lua
16+
Redis.Get(key, callback);
17+
Redis.Set(key, values, callback);
18+
Redis.Del(key, callback);
19+
Redis.Exist(key, callback);
20+
Redis.Expire(key, seconds, callback);
21+
Redis.Update(key, value, callback);
22+
Redis.Flush(callback);
23+
Redis.Keys(pattern, callback);
24+
Redis.MGet(keys, callback);
25+
Redis.Close();
26+
Redis.Open();
27+
Redis.Reload();
28+
```
29+
30+
#### Params
31+
- ```key/s(*)``` is the key or keys that you want to use in the query, if you want to use more than one key you have to use an array of keys.
32+
- ```values(depending)``` is the value or values that you want to set in an entry, if you want to use more than one value you have to use an array of values.
33+
- ```callback(optional)``` is the function that will be called when the data or function is finished, if the callback is not specified the query will be executed and it will be as an await function.
34+
35+
#### Examples
36+
##### Set
37+
```lua
38+
local result = exports["ice_mysql"]:RedisSet("name", "Daniel");
39+
-- OK
40+
```
41+
##### Update
42+
```lua
43+
local result = exports["ice_mysql"]:RedisUpdate("name", "Daniel3");
44+
-- OK
45+
```
46+
##### Get
47+
```lua
48+
local result = exports["ice_mysql"]:RedisGet("name");
49+
-- Daniel3
50+
```
51+
##### Delete
52+
```lua
53+
local result = exports["ice_mysql"]:RedisDel("name");
54+
-- OK
55+
```
56+
##### Flush
57+
```lua
58+
local result = exports["ice_mysql"]:RedisFlush();
59+
-- OK
60+
```
61+
62+
### Files
63+
This is the list of the involved files in this feature to help any developer to understand how it works:
64+
- ```src/db/redis/index.js```

src/db/redis/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ global.exports('RedisExpire', async (key, seconds, callback) => {
7474
}
7575
});
7676

77-
global.exports('RedisUpdate', async (key, value, newData, callback) => {
77+
global.exports('RedisUpdate', async (key, value, callback) => {
7878
try {
79-
const result = await client.update(key, value, newData);
79+
const result = await client.update(key, value, "XX");
8080
return callback ? callback(result) : result;
8181
} catch (err) {
8282
Log(LogTypes.Error, "Redis error while updating data: " + err.message);

0 commit comments

Comments
 (0)