Skip to content

Commit 9acad55

Browse files
author
chenby
committed
v0.4.1
1 parent 7681388 commit 9acad55

File tree

8 files changed

+46
-11
lines changed

8 files changed

+46
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ hs_err_pid*
3838
# Vscode
3939
/.vscode
4040
.factorypath
41+
42+
# log
43+
/log/

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 0.4.1
2+
3+
export unit support. [issue#16](https://github.com/leonchen83/redis-rdb-cli/issues/16).
4+
5+
16
### 0.4.0
27

38
Jsonl support. [issue#13](https://github.com/leonchen83/redis-rdb-cli/issues/13).

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,11 @@ docker-compose down
392392
```
393393

394394
`cd /path/to/redis-rdb-cli/conf/redis-rdb-cli.conf`
395-
Then change parameter [metric_gateway](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L161) from `none` to `influxdb`.
395+
Then change parameter [metric_gateway](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L168) from `none` to `influxdb`.
396396

397397
Open `http://localhost:3000` to check the `rct -f mem`'s result.
398398

399-
If you deployed this tool in multi instance, you need to change parameter [metric_instance](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L207) to make sure unique between instances.
399+
If you deployed this tool in multi instance, you need to change parameter [metric_instance](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L215) to make sure unique between instances.
400400

401401
## Redis 6
402402

@@ -414,8 +414,8 @@ $openssl pkcs12 -export -CAfile ca.crt -in redis.crt -inkey redis.key -out redis
414414
```
415415

416416
2. If source redis and target redis use the same keystore. then config following parameters
417-
[source_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L223) and [target_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L252) to point to `/path/to/redis-6.0-rc1/tests/tls/redis.p12`
418-
set [source_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L231) and [target_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L260)
417+
[source_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L231) and [target_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L260) to point to `/path/to/redis-6.0-rc1/tests/tls/redis.p12`
418+
set [source_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L239) and [target_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L268)
419419

420420
3. after config ssl parameters use `rediss://host:port` in your command to open ssl, for example: `rst -s rediss://127.0.0.1:6379 -m rediss://127.0.0.1:30001 -r -d 0`
421421

README.zh_CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,11 @@ docker-compose down
392392
```
393393

394394
`cd /path/to/redis-rdb-cli/conf/redis-rdb-cli.conf`
395-
[metric_gateway](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L161) 这个参数从 `none` 改成 `influxdb`
395+
[metric_gateway](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L169) 这个参数从 `none` 改成 `influxdb`
396396

397397
浏览器打开 `http://localhost:3000` 来查看 `rct -f mem` 命令的结果.
398398

399-
如果你把这个工具部署在多个实例上, 需要更改如下参数 [metric_instance](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L207) 并保证在每个实例上参数名唯一
399+
如果你把这个工具部署在多个实例上, 需要更改如下参数 [metric_instance](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L215) 并保证在每个实例上参数名唯一
400400

401401
## Redis 6
402402

@@ -414,8 +414,8 @@ $openssl pkcs12 -export -CAfile ca.crt -in redis.crt -inkey redis.key -out redis
414414
```
415415

416416
2. 如果源 redis 和目标 redis 使用同样的 keystore. 那么配置如下参数
417-
[source_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L223)[target_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L252) 指向 `/path/to/redis-6.0-rc1/tests/tls/redis.p12`
418-
设置 [source_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L231)[target_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L260)
417+
[source_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L231)[target_keystore_path](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L260) 指向 `/path/to/redis-6.0-rc1/tests/tls/redis.p12`
418+
设置 [source_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L239)[target_keystore_pass](https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/resources/redis-rdb-cli.conf#L268)
419419

420420
3. 在配置完 ssl 参数之后, 在你的命令中使用 `rediss://host:port` 这样的URI来开启ssl, 比如: `rst -s rediss://127.0.0.1:6379 -m rediss://127.0.0.1:30001 -r -d 0`
421421

src/main/java/com/moilioncircle/redis/rdb/cli/conf/Configure.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ private Configure(Properties properties) {
8585
* rct export meta
8686
*/
8787
private boolean exportMeta = true;
88+
89+
/**
90+
* rct export meta
91+
*/
92+
private boolean exportUnit = true;
8893

8994
/**
9095
* rmt --migrate
@@ -263,6 +268,14 @@ public void setExportMeta(boolean exportMeta) {
263268
this.exportMeta = exportMeta;
264269
}
265270

271+
public boolean isExportUnit() {
272+
return exportUnit;
273+
}
274+
275+
public void setExportUnit(boolean exportUnit) {
276+
this.exportUnit = exportUnit;
277+
}
278+
266279
public int getTimeout() {
267280
return timeout;
268281
}
@@ -562,6 +575,7 @@ public static Configure bind(Properties properties) {
562575
conf.quote = (byte) getString(conf, "quote", "\"", true).charAt(0);
563576
conf.delimiter = (byte) getString(conf, "delimiter", ",", true).charAt(0);
564577
conf.exportMeta = getBool(conf, "export_meta", true, true);
578+
conf.exportUnit = getBool(conf, "export_unit", true, true);
565579
conf.retries = getInt(conf, "retries", 5, true);
566580
conf.retryInterval = getInt(conf, "retry_interval", 1000, true);
567581
conf.timeout = getInt(conf, "timeout", 30000, true);
@@ -768,6 +782,7 @@ public String toString() {
768782
", quote=" + quote +
769783
", delimiter=" + delimiter +
770784
", exportMeta=" + exportMeta +
785+
", exportUnit=" + exportUnit +
771786
", migrateBatchSize=" + migrateBatchSize +
772787
", migrateThreads=" + migrateThreads +
773788
", migrateRetries=" + migrateRetries +

src/main/java/com/moilioncircle/redis/rdb/cli/ext/rct/MemRdbVisitor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ public void accept(Tuple2Ex tuple) {
102102
delimiter(out);
103103
quote(kv.getKey(), out);
104104
delimiter(out);
105-
quote(com.moilioncircle.redis.rdb.cli.util.Strings.pretty(tuple.getV1()).getBytes(), out, false);
105+
quote(pretty(tuple.getV1()).getBytes(), out, false);
106106
delimiter(out);
107107
OutputStreams.write(DataType.type(kv.getValueRdbType()).getBytes(), out);
108108
delimiter(out);
109109
OutputStreams.write(String.valueOf(kv.getLength()).getBytes(), out);
110110
delimiter(out);
111-
quote(com.moilioncircle.redis.rdb.cli.util.Strings.pretty(kv.getMax()).getBytes(), out, false);
111+
quote(pretty(kv.getMax()).getBytes(), out, false);
112112
delimiter(out);
113113
if (kv.getExpiredType() != NONE) {
114114
quote(FORMATTER.format(ofEpochMilli(kv.getExpiredValue()).atZone(systemDefault())).getBytes(), out, false);
@@ -118,6 +118,11 @@ public void accept(Tuple2Ex tuple) {
118118
OutputStreams.write('\n', out);
119119
}
120120

121+
private String pretty(long value) {
122+
if (!configure.isExportUnit()) return String.valueOf(value);
123+
return com.moilioncircle.redis.rdb.cli.util.Strings.pretty(value);
124+
}
125+
121126
@Override
122127
public void onEvent(Replicator replicator, Event event) {
123128
if (event instanceof DummyKeyValuePair) {

src/main/resources/.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.4.0
1+
v0.4.1

src/main/resources/redis-rdb-cli.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ quote=\u0022
7676
#
7777
export_meta=true
7878

79+
#
80+
# This parameter used in `rct` like the following
81+
# `rct -f mem -s ./dump.rdb -o ./dump.mem`
82+
# If this value is true. the exported data will with unit like B, kB, MB.
83+
#
84+
export_unit=true
85+
7986
#
8087
# Socket parameter
8188
# Used in connection timeout and read timeout

0 commit comments

Comments
 (0)