本文整理汇总了Java中redis.clients.jedis.Jedis.connect方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.connect方法的具体用法?Java Jedis.connect怎么用?Java Jedis.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.connect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static void main(String[] args) throws UnknownHostException, IOException {
Jedis jedis = new Jedis(hnp.getHost(), hnp.getPort());
jedis.connect();
jedis.auth("foobared");
jedis.flushAll();
long begin = Calendar.getInstance().getTimeInMillis();
Pipeline p = jedis.pipelined();
for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
String key = "foo" + n;
p.set(key, "bar" + n);
p.get(key);
}
p.sync();
long elapsed = Calendar.getInstance().getTimeInMillis() - begin;
jedis.disconnect();
System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
}
示例2: main
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static void main(String[] args) throws UnknownHostException, IOException {
Jedis jedis = new Jedis(hnp.getHost(), hnp.getPort());
jedis.connect();
jedis.auth("foobared");
jedis.flushAll();
long begin = Calendar.getInstance().getTimeInMillis();
for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
String key = "foo" + n;
jedis.set(key, "bar" + n);
jedis.get(key);
}
long elapsed = Calendar.getInstance().getTimeInMillis() - begin;
jedis.disconnect();
System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
}
示例3: makeObject
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public PooledObject<Jedis> makeObject() throws Exception {
final HostAndPort hostAndPort = this.hostAndPort.get();
JaRedis.Builder builder = new JaRedis.Builder();
builder
.host(hostAndPort.getHost())
.port(hostAndPort.getPort())
.connectionTimeout(connectionTimeout)
.soTimeout(soTimeout);
Jedis jedis = builder.build();
try {
jedis.connect();
if (null != this.password) {
jedis.auth(this.password);
}
if (database != 0) {
jedis.select(database);
}
if (clientName != null) {
jedis.clientSetname(clientName);
}
} catch (JedisException je) {
jedis.close();
throw je;
}
return new DefaultPooledObject<>(jedis);
}
示例4: setUp
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
jedis = new Jedis(hnp.getHost(), hnp.getPort(), 500);
jedis.connect();
jedis.auth("foobared");
jedis.configSet("timeout", "300");
jedis.flushAll();
}
示例5: createJedis
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
protected Jedis createJedis() {
Jedis j = new Jedis(hnp.getHost(), hnp.getPort());
j.connect();
j.auth("foobared");
j.flushAll();
return j;
}
示例6: setUp
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
nj = new Jedis(hnp.getHost(), hnp.getPort(), 500);
nj.connect();
nj.auth("foobared");
nj.flushAll();
}
示例7: main
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Jedis j = new Jedis(hnp.getHost(), hnp.getPort());
j.connect();
j.auth("foobared");
j.flushAll();
j.quit();
j.disconnect();
long t = System.currentTimeMillis();
// withoutPool();
withPool();
long elapsed = System.currentTimeMillis() - t;
System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
}
示例8: main
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Jedis j = new Jedis("127.0.0.1", 6379);
j.connect();
j.auth("weimob123");
j.flushAll();
j.quit();
j.disconnect();
long t = System.currentTimeMillis();
// withoutPool();
withPool();
long elapsed = System.currentTimeMillis() - t;
System.out.println(((1000 * TOTAL_OPERATIONS) / elapsed) + " ops");
}
示例9: get
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Dependent
@Produces
public Jedis get(InjectionPoint ip) {
System.out.println("injecting Jedis into " + ip.getMember().getDeclaringClass().getSimpleName());
String redisHost = System.getenv().getOrDefault("REDIS_HOST", "192.168.99.100");
String redisPort = System.getenv().getOrDefault("REDIS_PORT", "6379");
Jedis jedis = new Jedis(redisHost, Integer.valueOf(redisPort), 10000);
jedis.connect();
System.out.println("Redis Connection obtained");
return jedis;
}