Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master eval 1206 #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ public void eval(RedisRequest request) throws IOException {

private void evalOut(RedisOutputProtocol outputProtocol, LuaValue res) throws IOException {
if (res.isnil()) {
outputProtocol.writer("nil");
outputProtocol.writerNull();
}else if (res instanceof LuaTable){ //list case
LuaTable resTable = (LuaTable) res;
LuaValue len = resTable.len();
Original file line number Diff line number Diff line change
@@ -119,4 +119,25 @@ public void evalHashGet() {

assertEquals(key[1], a);
}

@Test
public void evalReturnNullTest() {
String[] key = new String[]{"JLF:INVOICE:227:com.jlf.invoice.service.impl.InvoiceInvoicingServiceImpl:red;"};
String[] val = new String[]{"30000", "e2e6465d-c943-4787-a2d7-93877786687e:1"};
Object a = jedis.eval(
"if (redis.call('exists', KEYS[1]) == 0) then " +
"redis.call('hincrby', KEYS[1], ARGV[2], 1); " +
"redis.call('pexpire', KEYS[1], ARGV[1]); " +
"return nil; " +
"end; " +
"if (redis.call('hexists', KEYS[1], ARGV[2]) == 1) then " +
"redis.call('hincrby', KEYS[1], ARGV[2], 1); " +
"redis.call('pexpire', KEYS[1], ARGV[1]); " +
"return nil; " +
"end; " +
"return redis.call('pttl', KEYS[1]);",
Arrays.asList(key),
Arrays.asList(val));
System.out.println("a:" + a);
}
}