-
Notifications
You must be signed in to change notification settings - Fork 569
Java example (lettuce)
Lars Meijer edited this page Feb 21, 2017
·
5 revisions
All Tile38 commands should be sent using the client.execute_command(command)
function.
import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.api.StatefulRedisConnection;
import com.lambdaworks.redis.codec.StringCodec;
import com.lambdaworks.redis.output.StatusOutput;
import com.lambdaworks.redis.protocol.CommandArgs;
import com.lambdaworks.redis.protocol.CommandType;
/**
* Example for using Tile38 in Java using lettuce version 5.0.1.Beta
*/
public class example {
public static void main(String[] args) {
RedisClient client = RedisClient.create("redis://localhost:9851");
StatefulRedisConnection<String, String> connection = client.connect();
StringCodec codec = StringCodec.UTF8;
connection.sync().dispatch(CommandType.SET,
new StatusOutput<>(codec), new CommandArgs<>(codec)
.add("fleet")
.add("truck1")
.add("POINT")
.add(33L)
.add(-115L));
String result = connection.sync().dispatch(CommandType.GET,
new StatusOutput<>(codec), new CommandArgs<>(codec)
.add("fleet")
.add("truck1"));
System.out.println(result);
}
}