当前位置: 首页>>代码示例>>Java>>正文


Java Jedis.auth方法代码示例

本文整理汇总了Java中redis.clients.jedis.Jedis.auth方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.auth方法的具体用法?Java Jedis.auth怎么用?Java Jedis.auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.auth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkJedisIsReusedWhenReturned

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void checkJedisIsReusedWhenReturned() {

  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "0");
  pool.returnResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:JedisPoolTest.java

示例2: testResetStateWithFullyExecutedTransaction

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void testResetStateWithFullyExecutedTransaction() {
  Jedis jedis2 = new Jedis(jedis.getClient().getHost(), jedis.getClient().getPort());
  jedis2.auth("foobared");

  Transaction t = jedis2.multi();
  t.set("mykey", "foo");
  t.get("mykey");

  List<Object> resp = t.exec();
  assertNotNull(resp);
  assertEquals(2, resp.size());

  jedis2.resetState();
  jedis2.close();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:TransactionCommandsTest.java

示例3: 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");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:23,代码来源:PipelinedGetSetBenchmark.java

示例4: 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");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:21,代码来源:GetSetBenchmark.java

示例5: timeoutConnection

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test(expected = JedisConnectionException.class)
public void timeoutConnection() throws Exception {
  jedis = new Jedis("localhost", 6379, 15000);
  jedis.auth("foobared");
  jedis.configSet("timeout", "1");
  Thread.sleep(2000);
  jedis.hmget("foobar", "foo");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:JedisTest.java

示例6: getNumActiveReturnsTheCorrectNumber

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void getNumActiveReturnsTheCorrectNumber() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));

  assertEquals(1, pool.getNumActive());

  Jedis jedis2 = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");

  assertEquals(2, pool.getNumActive());

  pool.returnResource(jedis);
  assertEquals(1, pool.getNumActive());

  pool.returnResource(jedis2);

  assertEquals(0, pool.getNumActive());

  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:JedisPoolTest.java

示例7: getResource

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private Jedis getResource() {
    Jedis resource = jedisPool.getResource();
    if (StringUtils.isBlank(password)) {
        return resource;
    } else {
        resource.auth(password);
        return resource;
    }
}
 
开发者ID:xubinux,项目名称:xbin-store,代码行数:10,代码来源:JedisClientSingle.java

示例8: 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);
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:28,代码来源:JaRedisFactory.java

示例9: startWithUrlString

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void startWithUrlString() {
  Jedis j = new Jedis("localhost", 6380);
  j.auth("foobared");
  j.select(2);
  j.set("foo", "bar");
  Jedis jedis = new Jedis("redis://:[email protected]:6380/2");
  assertEquals("PONG", jedis.ping());
  assertEquals("bar", jedis.get("foo"));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:11,代码来源:JedisTest.java

示例10: 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();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:TransactionCommandsTest.java

示例11: testBitfield

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void testBitfield() {
  Jedis jedis = new Jedis("redis://localhost:6380");
  jedis.auth("foobared");
  jedis.del("mykey");
  try {
    List<Long> responses = jedis.bitfield("mykey", "INCRBY","i5","100","1", "GET", "u4", "0");
    assertEquals(1l, responses.get(0).longValue());
    assertEquals(0l, responses.get(1).longValue());
  } finally {
    jedis.del("mykey");
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:14,代码来源:JedisTest.java

示例12: setUp

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {

  node1 = new Jedis(nodeInfo1.getHost(), nodeInfo1.getPort());
  node1.auth("cluster");
  node1.flushAll();

  node2 = new Jedis(nodeInfo2.getHost(), nodeInfo2.getPort());
  node2.auth("cluster");
  node2.flushAll();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:ClusterCommandsTest.java

示例13: checkCloseableConnections

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void checkCloseableConnections() throws Exception {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();

  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
      "foobared", 2);
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));
  pool.returnResource(jedis);
  pool.close();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:JedisSentinelPoolTest.java

示例14: startWithUrl

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void startWithUrl() throws URISyntaxException {
  Jedis j = new Jedis("localhost", 6380);
  j.auth("foobared");
  j.select(2);
  j.set("foo", "bar");
  Jedis jedis = new Jedis(new URI("redis://:[email protected]st:6380/2"));
  assertEquals("PONG", jedis.ping());
  assertEquals("bar", jedis.get("foo"));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:11,代码来源:JedisTest.java

示例15: connectWithoutShardInfo

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * Tests opening a default SSL/TLS connection to redis.
 */
@Test
public void connectWithoutShardInfo() {
  // The "rediss" scheme instructs jedis to open a SSL/TLS connection.
  Jedis jedis = new Jedis(URI.create("rediss://localhost:6390"));
  jedis.auth("foobared");
  jedis.get("foo");
  jedis.close();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:SSLJedisTest.java


注:本文中的redis.clients.jedis.Jedis.auth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。