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

leonchen83 / redis-replicator / #2250

08 Jun 2025 09:48AM UTC coverage: 71.988% (-0.2%) from 72.152%
#2250

push

leonchen83
redis-8.0

86 of 136 new or added lines in 11 files covered. (63.24%)

5 existing lines in 2 files now uncovered.

7062 of 9810 relevant lines covered (71.99%)

0.72 hits per line

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

85.0
/src/main/java/com/moilioncircle/redis/replicator/cmd/parser/ExpireParser.java
1
/*
2
 * Copyright 2016-2018 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.toInt;
21
import static com.moilioncircle.redis.replicator.cmd.CommandParsers.toRune;
22
import static com.moilioncircle.redis.replicator.util.Strings.isEquals;
23

24
import com.moilioncircle.redis.replicator.cmd.CommandParser;
25
import com.moilioncircle.redis.replicator.cmd.impl.CompareType;
26
import com.moilioncircle.redis.replicator.cmd.impl.ExistType;
27
import com.moilioncircle.redis.replicator.cmd.impl.ExpireCommand;
28

29
/**
30
 * @author Leon Chen
31
 * @since 2.1.0
32
 */
33
public class ExpireParser implements CommandParser<ExpireCommand> {
1✔
34
    @Override
35
    public ExpireCommand parse(Object[] command) {
36
        int idx = 1;
1✔
37
        byte[] key = toBytes(command[idx]);
1✔
38
        idx++;
1✔
39
        int ex = toInt(command[idx++]);
1✔
40
        
41
        ExistType existType = ExistType.NONE;
1✔
42
        CompareType compareType = CompareType.NONE;
1✔
43
        while (idx < command.length) {
1✔
44
            String param = toRune(command[idx]);
1✔
45
            if (isEquals(param, "NX")) {
1✔
NEW
46
                existType = ExistType.NX;
×
47
            } else if (isEquals(param, "XX")) {
1✔
48
                existType = ExistType.XX;
1✔
49
            } else if (isEquals(param, "GT")) {
1✔
50
                compareType = CompareType.GT;
1✔
NEW
51
            } else if (isEquals(param, "LT")) {
×
NEW
52
                compareType = CompareType.LT;
×
53
            }
54
            idx++;
1✔
55
        }
1✔
56
        return new ExpireCommand(key, ex, existType, compareType);
1✔
57
    }
58

59
}
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