Skip to content

Commit 7fa71c0

Browse files
Update README.md
1 parent 66238af commit 7fa71c0

File tree

1 file changed

+131
-28
lines changed
  • APIJSON-Java-Server/APIJSONDemo-MultiDataSource-RediSQL

1 file changed

+131
-28
lines changed
Lines changed: 131 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,151 @@
11
# APIJSONDemo
22

3-
## 支持多数据源-消息队列
3+
## 支持多数据源-rediSQL
44

5-
示例:kafka
5+
redis table 表名规范: REDIS_TABLE_* <br/>
6+
开发人员可自行控制 <br/>
7+
JedisBuildData <br/>
8+
public static final String REDIS_TABLE_KEY = "REDIS_TABLE_"; // rediSql table prefix <br/>
69

7-
原理说明:
10+
Access、Request配置 访问操作权限 <br/>
811

9-
Access表名 = 消息队列 topic
12+
rediSQL安装使用 <br/>
13+
https://github.com/RedBeardLab/rediSQL
1014

11-
Access表配置说明:
12-
![image](https://user-images.githubusercontent.com/12228225/210956299-204115a7-433c-4f18-af27-5120068dab2e.png)
13-
Request表配置post权限
14-
![image](https://user-images.githubusercontent.com/12228225/210956378-be095589-0ced-4317-bb46-6b296538f26e.png)
15+
官方docker安装 <br/>
16+
docker pull dalongrong/redisql
17+
docker run -itd --name redisql -p 6399:6379 dalongrong/redisql
1518

16-
apijson发送mq消息:
17-
单条<br/>
19+
rediSQL注意事项 <br/>
20+
rediSQL免费版有后遥控制,每个小时会发送 redist info 统计信息<br/>
21+
<img width="1000" alt="image" src="https://user-images.githubusercontent.com/12228225/219613765-e8d4d963-035b-4352-9552-1ce3a14093e4.png">
22+
23+
可以配host ,弄一个nginx 本地代理 解决,或者 项目自己重新打包<br/>
24+
25+
rediSQL java:<br/>
26+
https://github.com/RedBeardLab/JRediSQL<br/>
27+
https://www.youtube.com/watch?v=YRusC-AIq_g
28+
29+
rediSQL 创建数据库表命令 <br/>
30+
```
31+
REDISQL.EXEC DB "CREATE TABLE REDIS_TABLE_A(id TEXT, A INT, B TEXT, C TEXT, userId TEXT);"
32+
33+
REDISQL.EXEC DB "INSERT INTO REDIS_TABLE_A(id,A,B,C,userId) VALUES('1', 3, '1c', 'bar','1');"
34+
35+
36+
REDISQL.EXEC DB "SELECT * FROM REDIS_TABLE_A;"
37+
38+
REDISQL.EXEC DB "drop table REDIS_TABLE_A;"
39+
```
40+
41+
测试用例<br/>
42+
```
1843
{
19-
"@datasource": "kafka",
20-
"Topic_User":{
21-
"message":"test-101"
44+
"@datasource": "redisCluster",
45+
"REDIS_TABLE_A":{
46+
"A": 1,
47+
"B": "B",
48+
"C": "C"
2249
},
23-
"tag": "Topic_User",
24-
"@explain": false
25-
}<br/>
26-
多条<br/>
50+
"tag": "REDIS_TABLE_A",
51+
"@explain": true,
52+
"format": true
53+
}
54+
2755
{
28-
"Topic_User[]": [
56+
"REDIS_TABLE_A[]": [
57+
{
58+
"A": 5,
59+
"B": "5B",
60+
"C": "5C"
61+
},
2962
{
30-
"message":"test-100"
63+
"A": 6,
64+
"B": "6B",
65+
"C": "6C"
3166
},
3267
{
33-
"message":"test-101"
68+
"A": 7,
69+
"B": "7B",
70+
"C": "7C"
3471
}
3572
],
36-
"tag": "Topic_User[]",
37-
"@datasource": "kafka",
38-
"@explain": true
73+
"tag": "REDIS_TABLE_A[]",
74+
"@datasource": "redisCluster",
75+
"@explain": true,
76+
"format": true
77+
}
78+
79+
{
80+
"@datasource": "redisCluster",
81+
"REDIS_TABLE_A": {
82+
"id": "f2621698-99fa-4698-9fb0-8c7b585da403",
83+
"A": 1,
84+
"B": "1B"
85+
},
86+
"tag": "REDIS_TABLE_A",
87+
"@explain": true,
88+
"format": true
89+
}
90+
91+
Request 表配置
92+
{"REDIS_TABLE_A[]": [{"MUST": "A,B", "REFUSE": "id"}], "INSERT": {"@role": "OWNER,ADMIN","@combine": "A | B"}}
93+
94+
{
95+
"@datasource": "redisCluster",
96+
"REDIS_TABLE_A": {
97+
"A": 1,
98+
"B": "1B",
99+
"C": "1-1-1C"
100+
},
101+
"tag": "REDIS_TABLE_A",
102+
"@explain": true,
103+
"format": true
39104
}
40105
41-
客户端接收消息:
106+
{
107+
"@datasource": "redisCluster",
108+
"REDIS_TABLE_A:a": {
109+
"@column":"a,b,c",
110+
"b$": "7B%"
111+
},
112+
"@explain": true,
113+
"format": true
114+
}
42115
43-
offset = 47, key = null, value = test-101<br/>
44-
offset = 48, key = null, value = test-100<br/>
45-
offset = 49, key = null, value = test-101<br/>
116+
{
117+
"@datasource": "redisCluster",
118+
"REDIS_TABLE_A:a[]": {
119+
"REDIS_TABLE_A": {
120+
"@column":"a,b,c"
121+
//"b$": "1%"
122+
},
123+
"page":0,
124+
"count":3,
125+
"query": 2
126+
},
127+
"total@": "/REDIS_TABLE_A:a[]/total",
128+
"@explain": true,
129+
"format": true
130+
}
46131
132+
{
133+
"@datasource": "redisCluster",
134+
"REDIS_TABLE_A": {
135+
"id": "f2621698-99fa-4698-9fb0-8c7b585da403"
136+
},
137+
"tag": "REDIS_TABLE_A",
138+
"@explain": true,
139+
"format": true
140+
}
47141
48-
用java代码方式,获取具体数据源,调用即可
142+
{
143+
"@datasource": "redisCluster",
144+
"REDIS_TABLE_A:a": {
145+
"id{}": ["1","eb3dd7c9-bab6-410c-b70a-cbbc3bd12896", "c83b3cfa-034e-4a9e-b2cf-83520db1ce05"]
146+
},
147+
"tag": "REDIS_TABLE_A[]",
148+
"@explain": true,
149+
"format": true
150+
}
151+
```

0 commit comments

Comments
 (0)