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

leonchen83 / redis-replicator / #2273

08 Jun 2025 10:35AM UTC coverage: 71.537% (+0.04%) from 71.499%
#2273

push

leonchen83
redis-8.0

0 of 1 new or added line in 1 file covered. (0.0%)

7095 of 9918 relevant lines covered (71.54%)

0.72 hits per line

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

2.13
/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) {
37
        byte[] key = toBytes(command[1]);
×
NEW
38
        int idx = 2;
×
39
        FieldExistType existType = FieldExistType.NONE;
×
40
        Long expiredValue = null;
×
41
        XATType xatType = XATType.NONE;
×
42
        Long xatValue = null;
×
43
        boolean et = false, st = false;
×
44
        boolean keepTtl = false;
×
45
        ExpiredType expiredType = ExpiredType.NONE;
×
46
        while (idx < command.length) {
×
47
            String param = toRune(command[idx++]);
×
48
            if (!et && isEquals(param, "FNX")) {
×
49
                existType = FieldExistType.FNX;
×
50
                et = true;
×
51
            } else if (!et && isEquals(param, "FXX")) {
×
52
                existType = FieldExistType.FXX;
×
53
                et = true;
×
54
            } else if (!keepTtl && isEquals(param, "KEEPTTL")) {
×
55
                keepTtl = true;
×
56
            }
57
            
58
            if (!st && isEquals(param, "EX")) {
×
59
                expiredType = ExpiredType.SECOND;
×
60
                expiredValue = Long.valueOf(toRune(command[idx++]));
×
61
                st = true;
×
62
            } else if (!st && isEquals(param, "PX")) {
×
63
                expiredType = ExpiredType.MS;
×
64
                expiredValue = Long.valueOf(toRune(command[idx++]));
×
65
                st = true;
×
66
            } else if (!st && isEquals(param, "EXAT")) {
×
67
                xatType = XATType.EXAT;
×
68
                xatValue = Long.valueOf(toRune(command[idx++]));
×
69
                st = true;
×
70
            } else if (!st && isEquals(param, "PXAT")) {
×
71
                xatType = XATType.PXAT;
×
72
                xatValue = Long.valueOf(toRune(command[idx++]));
×
73
                st = true;
×
74
            }
75
            
76
            if (isEquals(param, "FIELDS")) {
×
77
                break;
×
78
            }
79
        }
×
80
        
81
        idx += 2; // skip FIELDS numFields
×
82
        int n = command.length - idx;
×
83
        byte[][] fields = new byte[n / 2][];
×
84
        byte[][] values = new byte[n / 2][];
×
85
        for (int i = idx, j = 0; i < command.length; i += 2, j++) {
×
86
            fields[j] = toBytes(command[i]);
×
87
            values[j] = toBytes(command[i + 1]);
×
88
        }
89
        
90
        return new HSetExCommand(key, fields, values, keepTtl, expiredType, expiredValue, xatType, xatValue, existType);
×
91
    }
92
    
93
}
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