Java Code Examples for redis.clients.jedis.Jedis#flushDB()
The following examples show how to use
redis.clients.jedis.Jedis#flushDB() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InitTask.java From jseckill with Apache License 2.0 | 6 votes |
/** * 预热秒杀数据到Redis */ private void initRedis() { Jedis jedis = jedisPool.getResource(); //清空Redis缓存 jedis.flushDB(); List<Seckill> seckillList = seckillDAO.queryAll(0, 10); if (seckillList == null || seckillList.size()< 1) { logger.info("--FatalError!!! seckill_list_data is empty"); return; } for (Seckill seckill : seckillList) { jedis.sadd(RedisKey.SECKILL_ID_SET, seckill.getSeckillId() + ""); String inventoryKey = RedisKeyPrefix.SECKILL_INVENTORY + seckill.getSeckillId(); jedis.set(inventoryKey, String.valueOf(seckill.getInventory())); String seckillGoodsKey = RedisKeyPrefix.SECKILL_GOODS + seckill.getSeckillId(); byte[] goodsBytes = ProtostuffIOUtil.toByteArray(seckill, MyRuntimeSchema.getInstance().getGoodsRuntimeSchema(), LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE)); jedis.set(seckillGoodsKey.getBytes(), goodsBytes); } jedis.close(); logger.info("Redis缓存数据初始化完毕!"); }
Example 2
Source File: RedisHelper.java From yahoo-streaming-benchmark with Apache License 2.0 | 6 votes |
public void prepareRedis(Map<String, List<String>> campaigns) { Jedis redis = new Jedis(config.redisHost); redis.select(config.redisDb); if (config.redisFlush) { LOG.info("Flushing Redis DB."); redis.flushDB(); } LOG.info("Preparing Redis with campaign data."); for (Map.Entry<String, List<String>> entry : campaigns.entrySet()) { String campaign = entry.getKey(); redis.sadd("campaigns", campaign); for (String ad : entry.getValue()) { redis.set(ad, campaign); } } redis.close(); }
Example 3
Source File: JedisUtils.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
/** * <p> * 清空当前数据库中的所有 key,此命令从不失败。 * </p> * * @return 总是返回 OK */ public String flushDB() { Jedis jedis = null; try { jedis = jedisPool.getResource(); return jedis.flushDB(); } catch (Exception e) { log.error(e.getMessage()); } finally { returnResource(jedisPool, jedis); } return null; }
Example 4
Source File: RedisClient.java From flycache with Apache License 2.0 | 5 votes |
public String flushDB() { Jedis jedis = null; String result = null; try { jedis = jedisPool.getResource(); result = jedis.flushDB(); } catch (Exception e) { e.printStackTrace(); } finally { closeJedis(jedis); } return result; }
Example 5
Source File: CacheServiceRedisImpl.java From redis_util with Apache License 2.0 | 5 votes |
public void clearObject() { Jedis jedis = null; try { jedis = redisConnection.getJedis(); jedis.select(dbIndex); jedis.flushDB(); } catch (Exception e) { log.warn(e.getMessage(), e); } finally { if (jedis != null) { jedis.close(); } } }
Example 6
Source File: RedisManager.java From jee-universal-bms with Apache License 2.0 | 5 votes |
/** * flush */ public void flushDB() { Jedis jedis = pool.getResource(); try { jedis.flushDB(); } finally { pool.returnResource(jedis); } }
Example 7
Source File: RedisClientTest.java From nosql4idea with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { jedis = new Jedis("localhost", 6379); jedis.select(1); jedis.flushDB(); }
Example 8
Source File: DefaultRedis.java From craft-atom with MIT License | 4 votes |
private String flushdb0(Jedis j) { return j.flushDB(); }