This tutorial will introduce how to use Redis in zero system.
This chapter is duplicated with D10102 - Configuration, vertx-redis.yml, because that's the preparing steps for redis client.
Be sure the extension up.god.file name existing in lime
node:
zero:
lime: redis
vertx:
instance:
- name: vx-zero
options:
# Fix block 2000 limit issue.
maxEventLoopExecuteTime: 30000000000
redis: io.vertx.mod.plugin.redis.RedisInfix
redis:
host: 0.0.0.0
port: 6379
Just like vertx-mysql.yml
configuration, here all the redis
node keys are native supported by vert.x, you can
provide all the native configuration keys to redis
in zero system.
package up.god.micro.redis;
import io.vertx.redis.RedisClient;
import io.vertx.up.annotations.EndPoint;
import io.zerows.annotations.infix.Redis;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("")
@EndPoint
public class RedisActor {
@Redis
private transient RedisClient client;
@Path("/api/redis")
@GET
public String sayRedis(final String name) {
System.out.println(this.client);
return "Redis, " + name;
}
}
Here you can inject RedisClient based on above code.