redis.clients.jedis.Jedis.dbSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(301)

本文整理了Java中redis.clients.jedis.Jedis.dbSize()方法的一些代码示例,展示了Jedis.dbSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.dbSize()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:dbSize

Jedis.dbSize介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

/**
   * @throws Exception If failed.
   */
  @Test
  public void testFlushAll() throws Exception {
    try (Jedis jedis = pool.getResource()) {
      Assert.assertEquals(0, (long)jedis.dbSize());

      for (int i = 0; i < 100; i++)
        jedis.set(String.valueOf(i), String.valueOf(i));

      Assert.assertEquals(100, (long)jedis.dbSize());

      jedis.select(1);

      for (int i = 0; i < 100; i++)
        jedis.set(String.valueOf(i), String.valueOf(i));

      Assert.assertEquals(100, (long)jedis.dbSize());

      jedis.flushAll();

      Assert.assertEquals(0, (long)jedis.dbSize());

      jedis.select(0);

      Assert.assertEquals(0, (long)jedis.dbSize());
    }
  }
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testDbSize() throws Exception {
  try (Jedis jedis = pool.getResource()) {
    Assert.assertEquals(0, (long)jedis.dbSize());
    jcache().putAll(new HashMap<Integer, Integer>() {
      {
        for (int i = 0; i < 100; i++)
          put(i, i);
      }
    });
    Assert.assertEquals(100, (long)jedis.dbSize());
  }
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testFlushDb() throws Exception {
  try (Jedis jedis = pool.getResource()) {
    Assert.assertEquals(0, (long)jedis.dbSize());
    jcache().putAll(new HashMap<Integer, Integer>() {
      {
        for (int i = 0; i < 100; i++)
          put(i, i);
      }
    });
    Assert.assertEquals(100, (long)jedis.dbSize());
    jedis.select(1);
    jcache().putAll(new HashMap<Integer, Integer>() {
      {
        for (int i = 0; i < 100; i++)
          put(i, i);
      }
    });
    // flush database 1.
    jedis.flushDB();
    Assert.assertEquals(0, (long)jedis.dbSize());
    jedis.select(0);
    Assert.assertEquals(100, (long)jedis.dbSize());
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long dbSize() {
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().dbSize()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().dbSize()));
      return null;
    }
    return connection.getJedis().dbSize();
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: sanluan/PublicCMS

/**
 * @return
 */
public long dbSize() {
  Jedis jedis = jedisPool.getResource();
  long size = jedis.dbSize();
  jedis.close();
  return size;
}

代码示例来源:origin: sanluan/PublicCMS

/**
 * @return
 */
public long dbSize() {
  Jedis jedis = jedisPool.getResource();
  long size = jedis.dbSize();
  jedis.close();
  return size;
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
  public Object execute(Jedis jedis) {
    return jedis.dbSize();
  }
});

代码示例来源:origin: hltfbk/Excitement-Open-Platform

@Override
public int size() {
  //@TOTHINK
  return (int)(long)jedis.dbSize() / 2;
}

代码示例来源:origin: hltfbk/Excitement-Open-Platform

@Override
public int size() {
  return (int)(long)jedis.dbSize();
}

代码示例来源:origin: hltfbk/Excitement-Open-Platform

@Override
public boolean hasNext() {
  return count < (jedis.dbSize() / entriesPerItem);
}

代码示例来源:origin: hltfbk/Excitement-Open-Platform

@Override
public int size() {
  return (int)(long)jedis.dbSize();
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public Long getValue() {
    try (Jedis jedis = m_pool.getResource()) {
      return jedis.dbSize();
    }
  }
});

代码示例来源:origin: org.opennms.features/org.opennms.features.newts

@Override
  public Long getValue() {
    try (Jedis jedis = m_pool.getResource()) {
      return jedis.dbSize();
    }
  }
});

代码示例来源:origin: zhangyd-c/OneBlog

@Override
public Long dbSize() {
  Long dbSize = 0L;
  try (Jedis jedis = jedisPool.getResource()) {
    dbSize = jedis.dbSize();
  }
  return dbSize;
}

代码示例来源:origin: lordofthejars/nosql-unit

private static long countNumberOfAllElements(RedisConnectionCallback redisConnectionCallback) {
  long insertedElements = 0;
  
  for (Jedis jedis : redisConnectionCallback.getAllJedis()) {
    insertedElements += jedis.dbSize();
  }
  return insertedElements;
}

代码示例来源:origin: wang926454/ShiroJwt

/**
 * 缓存的个数
 */
@Override
public int size() {
  Long size = JedisUtil.getJedis().dbSize();
  return size.intValue();
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Long dbSize() {
 String command = "dbSize";
 return instrumented(command, () -> delegated.dbSize());
}

代码示例来源:origin: com.lordofthejars/nosqlunit-redis

private static long countNumberOfAllElements(RedisConnectionCallback redisConnectionCallback) {
  long insertedElements = 0;
  
  for (Jedis jedis : redisConnectionCallback.getAllJedis()) {
    insertedElements += jedis.dbSize();
  }
  return insertedElements;
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

/**
 * Return the number of keys in the currently selected database.
 *
 * @return Integer reply
 */
public Long dbSize() {
  Jedis jedis = getJedis();
  try {
    return jedis.dbSize();
  } finally {Streams.safeClose(jedis);}
}

代码示例来源:origin: xiangwbs/springboot

/**
 * 查看redis里有多少数据
 */
public long dbSize() {
  Jedis jedis = null;
  try {
    jedis = getJedis();
    return jedis.dbSize();
  } finally {
    returnJedis(jedis);
  }
}

相关文章

Jedis类方法