• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

leonchen83 / redis-replicator / #2268

08 Jun 2025 10:34AM UTC coverage: 71.499% (-0.6%) from 72.148%
#2268

push

leonchen83
redis-8.0

0 of 87 new or added lines in 3 files covered. (0.0%)

3 existing lines in 2 files now uncovered.

7092 of 9919 relevant lines covered (71.5%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.08
/src/main/java/com/moilioncircle/redis/replicator/cmd/parser/HSetExParser.java
1
/*
2
 * Copyright 2016-2017 Leon Chen
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.moilioncircle.redis.replicator.cmd.parser;
18

19
import static com.moilioncircle.redis.replicator.cmd.CommandParsers.toBytes;
20
import static com.moilioncircle.redis.replicator.cmd.CommandParsers.toRune;
21
import static com.moilioncircle.redis.replicator.util.Strings.isEquals;
22

23
import com.moilioncircle.redis.replicator.cmd.CommandParser;
24
import com.moilioncircle.redis.replicator.cmd.impl.FieldExistType;
25
import com.moilioncircle.redis.replicator.cmd.impl.HSetExCommand;
26
import com.moilioncircle.redis.replicator.cmd.impl.XATType;
27
import com.moilioncircle.redis.replicator.rdb.datatype.ExpiredType;
28

29
/**
30
 * @author Leon Chen
31
 * @since 3.9.0
32
 */
33
public class HSetExParser  implements CommandParser<HSetExCommand> {
1✔
34
    
35
    @Override
36
    public HSetExCommand parse(Object[] command) {
NEW
37
        byte[] key = toBytes(command[1]);
×
NEW
38
        byte[] value = toBytes(command[2]);
×
NEW
39
        int idx = 3;
×
NEW
40
        FieldExistType existType = FieldExistType.NONE;
×
NEW
41
        Long expiredValue = null;
×
NEW
42
        XATType xatType = XATType.NONE;
×
NEW
43
        Long xatValue = null;
×
NEW
44
        boolean et = false, st = false;
×
NEW
45
        boolean keepTtl = false;
×
NEW
46
        ExpiredType expiredType = ExpiredType.NONE;
×
NEW
47
        while (idx < command.length) {
×
NEW
48
            String param = toRune(command[idx++]);
×
NEW
49
            if (!et && isEquals(param, "FNX")) {
×
NEW
50
                existType = FieldExistType.FNX;
×
NEW
51
                et = true;
×
NEW
52
            } else if (!et && isEquals(param, "FXX")) {
×
NEW
53
                existType = FieldExistType.FXX;
×
NEW
54
                et = true;
×
NEW
55
            } else if (!keepTtl && isEquals(param, "KEEPTTL")) {
×
NEW
56
                keepTtl = true;
×
57
            }
58
            
NEW
59
            if (!st && isEquals(param, "EX")) {
×
NEW
60
                expiredType = ExpiredType.SECOND;
×
NEW
61
                expiredValue = Long.valueOf(toRune(command[idx++]));
×
NEW
62
                st = true;
×
NEW
63
            } else if (!st && isEquals(param, "PX")) {
×
NEW
64
                expiredType = ExpiredType.MS;
×
NEW
65
                expiredValue = Long.valueOf(toRune(command[idx++]));
×
NEW
66
                st = true;
×
NEW
67
            } else if (!st && isEquals(param, "EXAT")) {
×
NEW
68
                xatType = XATType.EXAT;
×
NEW
69
                xatValue = Long.valueOf(toRune(command[idx++]));
×
NEW
70
                st = true;
×
NEW
71
            } else if (!st && isEquals(param, "PXAT")) {
×
NEW
72
                xatType = XATType.PXAT;
×
NEW
73
                xatValue = Long.valueOf(toRune(command[idx++]));
×
NEW
74
                st = true;
×
75
            }
76
            
NEW
77
            if (isEquals(param, "FIELDS")) {
×
NEW
78
                break;
×
79
            }
NEW
80
        }
×
81
        
NEW
82
        idx += 2; // skip FIELDS numFields
×
NEW
83
        int n = command.length - idx;
×
NEW
84
        byte[][] fields = new byte[n / 2][];
×
NEW
85
        byte[][] values = new byte[n / 2][];
×
NEW
86
        for (int i = idx, j = 0; i < command.length; i += 2, j++) {
×
NEW
87
            fields[j] = toBytes(command[i]);
×
NEW
88
            values[j] = toBytes(command[i + 1]);
×
89
        }
90
        
NEW
91
        return new HSetExCommand(key, fields, values, keepTtl, expiredType, expiredValue, xatType, xatValue, existType);
×
92
    }
93
    
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc