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

Support Hash field expiration #3826

Merged
merged 12 commits into from
Jun 6, 2024
138 changes: 134 additions & 4 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -1140,10 +1140,6 @@ public final CommandObject<ScanResult<String>> hscanNoValues(String key, String
return new CommandObject<>(commandArguments(HSCAN).key(key).add(cursor).addParams(params).add(NOVALUES), BuilderFactory.SCAN_RESPONSE);
}

public final CommandObject<Long> hstrlen(String key, String field) {
return new CommandObject<>(commandArguments(HSTRLEN).key(key).add(field), BuilderFactory.LONG);
}

public final CommandObject<ScanResult<Map.Entry<byte[], byte[]>>> hscan(byte[] key, byte[] cursor, ScanParams params) {
return new CommandObject<>(commandArguments(HSCAN).key(key).add(cursor).addParams(params), BuilderFactory.HSCAN_BINARY_RESPONSE);
}
Expand All @@ -1152,9 +1148,143 @@ public final CommandObject<ScanResult<byte[]>> hscanNoValues(byte[] key, byte[]
return new CommandObject<>(commandArguments(HSCAN).key(key).add(cursor).addParams(params).add(NOVALUES), BuilderFactory.SCAN_BINARY_RESPONSE);
}

public final CommandObject<Long> hstrlen(String key, String field) {
return new CommandObject<>(commandArguments(HSTRLEN).key(key).add(field), BuilderFactory.LONG);
}

public final CommandObject<Long> hstrlen(byte[] key, byte[] field) {
return new CommandObject<>(commandArguments(HSTRLEN).key(key).add(field), BuilderFactory.LONG);
}

public final CommandObject<List<Long>> hexpire(String key, long seconds, String... fields) {
return new CommandObject<>(commandArguments(HEXPIRE).key(key).add(seconds)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpire(String key, long seconds, ExpiryOption condition, String... fields) {
return new CommandObject<>(commandArguments(HEXPIRE).key(key).add(seconds).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpire(String key, long milliseconds, String... fields) {
return new CommandObject<>(commandArguments(HPEXPIRE).key(key).add(milliseconds)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpire(String key, long milliseconds, ExpiryOption condition, String... fields) {
return new CommandObject<>(commandArguments(HPEXPIRE).key(key).add(milliseconds).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpireAt(String key, long unixTimeSeconds, String... fields) {
return new CommandObject<>(commandArguments(HEXPIREAT).key(key).add(unixTimeSeconds)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpireAt(String key, long unixTimeSeconds, ExpiryOption condition, String... fields) {
return new CommandObject<>(commandArguments(HEXPIREAT).key(key).add(unixTimeSeconds).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpireAt(String key, long unixTimeMillis, String... fields) {
return new CommandObject<>(commandArguments(HPEXPIREAT).key(key).add(unixTimeMillis)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpireAt(String key, long unixTimeMillis, ExpiryOption condition, String... fields) {
return new CommandObject<>(commandArguments(HPEXPIREAT).key(key).add(unixTimeMillis).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpire(byte[] key, long seconds, byte[]... fields) {
return new CommandObject<>(commandArguments(HEXPIRE).key(key).add(seconds)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpire(byte[] key, long seconds, ExpiryOption condition, byte[]... fields) {
return new CommandObject<>(commandArguments(HEXPIRE).key(key).add(seconds).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpire(byte[] key, long milliseconds, byte[]... fields) {
return new CommandObject<>(commandArguments(HPEXPIRE).key(key).add(milliseconds)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpire(byte[] key, long milliseconds, ExpiryOption condition, byte[]... fields) {
return new CommandObject<>(commandArguments(HPEXPIRE).key(key).add(milliseconds).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpireAt(byte[] key, long unixTimeSeconds, byte[]... fields) {
return new CommandObject<>(commandArguments(HEXPIREAT).key(key).add(unixTimeSeconds)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpireAt(byte[] key, long unixTimeSeconds, ExpiryOption condition, byte[]... fields) {
return new CommandObject<>(commandArguments(HEXPIREAT).key(key).add(unixTimeSeconds).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpireAt(byte[] key, long unixTimeMillis, byte[]... fields) {
return new CommandObject<>(commandArguments(HPEXPIREAT).key(key).add(unixTimeMillis)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpireAt(byte[] key, long unixTimeMillis, ExpiryOption condition, byte[]... fields) {
return new CommandObject<>(commandArguments(HPEXPIREAT).key(key).add(unixTimeMillis).add(condition)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpireTime(String key, String... fields) {
return new CommandObject<>(commandArguments(HEXPIRETIME).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpireTime(String key, String... fields) {
return new CommandObject<>(commandArguments(HPEXPIRETIME).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> httl(String key, String... fields) {
return new CommandObject<>(commandArguments(HTTL).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpttl(String key, String... fields) {
return new CommandObject<>(commandArguments(HPTTL).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hexpireTime(byte[] key, byte[]... fields) {
return new CommandObject<>(commandArguments(HEXPIRETIME).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpexpireTime(byte[] key, byte[]... fields) {
return new CommandObject<>(commandArguments(HPEXPIRETIME).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> httl(byte[] key, byte[]... fields) {
return new CommandObject<>(commandArguments(HTTL).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpttl(byte[] key, byte[]... fields) {
return new CommandObject<>(commandArguments(HPTTL).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpersist(String key, String... fields) {
return new CommandObject<>(commandArguments(HPERSIST).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<Long>> hpersist(byte[] key, byte[]... fields) {
return new CommandObject<>(commandArguments(HPERSIST).key(key)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.LONG_LIST);
}
// Hash commands

// Set commands
Expand Down
156 changes: 156 additions & 0 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4656,6 +4656,84 @@ public long hstrlen(final byte[] key, final byte[] field) {
return connection.executeCommand(commandObjects.hstrlen(key, field));
}

@Override
public List<Long> hexpire(byte[] key, long seconds, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpire(key, seconds, fields));
}

@Override
public List<Long> hexpire(byte[] key, long seconds, ExpiryOption condition, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpire(key, seconds, condition, fields));
}

@Override
public List<Long> hpexpire(byte[] key, long milliseconds, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpire(key, milliseconds, fields));
}

@Override
public List<Long> hpexpire(byte[] key, long milliseconds, ExpiryOption condition, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpire(key, milliseconds, condition, fields));
}

@Override
public List<Long> hexpireAt(byte[] key, long unixTimeSeconds, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpireAt(key, unixTimeSeconds, fields));
}

@Override
public List<Long> hexpireAt(byte[] key, long unixTimeSeconds, ExpiryOption condition, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpireAt(key, unixTimeSeconds, condition, fields));
}

@Override
public List<Long> hpexpireAt(byte[] key, long unixTimeMillis, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpireAt(key, unixTimeMillis, fields));
}

@Override
public List<Long> hpexpireAt(byte[] key, long unixTimeMillis, ExpiryOption condition, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpireAt(key, unixTimeMillis, condition, fields));
}

@Override
public List<Long> hexpireTime(byte[] key, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpireTime(key, fields));
}

@Override
public List<Long> hpexpireTime(byte[] key, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpireTime(key, fields));
}

@Override
public List<Long> httl(byte[] key, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.httl(key, fields));
}

@Override
public List<Long> hpttl(byte[] key, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpttl(key, fields));
}

@Override
public List<Long> hpersist(byte[] key, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpersist(key, fields));
}

@Override
public List<Object> xread(XReadParams xReadParams, Entry<byte[], byte[]>... streams) {
checkIsInMultiOrPipeline();
Expand Down Expand Up @@ -9237,6 +9315,84 @@ public long hstrlen(final String key, final String field) {
return connection.executeCommand(commandObjects.hstrlen(key, field));
}

@Override
public List<Long> hexpire(String key, long seconds, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpire(key, seconds, fields));
}

@Override
public List<Long> hexpire(String key, long seconds, ExpiryOption condition, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpire(key, seconds, condition, fields));
}

@Override
public List<Long> hpexpire(String key, long milliseconds, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpire(key, milliseconds, fields));
}

@Override
public List<Long> hpexpire(String key, long milliseconds, ExpiryOption condition, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpire(key, milliseconds, condition, fields));
}

@Override
public List<Long> hexpireAt(String key, long unixTimeSeconds, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpireAt(key, unixTimeSeconds, fields));
}

@Override
public List<Long> hexpireAt(String key, long unixTimeSeconds, ExpiryOption condition, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpireAt(key, unixTimeSeconds, condition, fields));
}

@Override
public List<Long> hpexpireAt(String key, long unixTimeMillis, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpireAt(key, unixTimeMillis, fields));
}

@Override
public List<Long> hpexpireAt(String key, long unixTimeMillis, ExpiryOption condition, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpireAt(key, unixTimeMillis, condition, fields));
}

@Override
public List<Long> hexpireTime(String key, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hexpireTime(key, fields));
}

@Override
public List<Long> hpexpireTime(String key, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpexpireTime(key, fields));
}

@Override
public List<Long> httl(String key, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.httl(key, fields));
}

@Override
public List<Long> hpttl(String key, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpttl(key, fields));
}

@Override
public List<Long> hpersist(String key, String... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hpersist(key, fields));
}

@Override
public String memoryDoctor() {
checkIsInMultiOrPipeline();
Expand Down
Loading
Loading