redis.clients.jedis.exceptions.JedisException Java Examples
The following examples show how to use
redis.clients.jedis.exceptions.JedisException.
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: JedisMock.java From conductor with Apache License 2.0 | 6 votes |
@Override public String hmset(final String key, final Map<String, String> hash) { try { String field = null, value = null; String[] args = new String[(hash.size() - 1)*2]; int idx = 0; for (String f : hash.keySet()) { if (field == null) { field = f; value = hash.get(f); continue; } args[idx] = f; args[idx + 1] = hash.get(f); idx += 2; } return redis.hmset(key, field, value, args); } catch (Exception e) { throw new JedisException(e); } }
Example #2
Source File: Redis.java From AntiVPN with MIT License | 6 votes |
private void deleteNamespace(Jedis redis, String namespace) throws JedisException { long current = 0; ScanParams params = new ScanParams(); params.match(namespace + "*"); params.count(50); ScanResult<String> result; do { result = redis.scan(String.valueOf(current), params); List<String> r = result.getResult(); if (!r.isEmpty()) { redis.del(r.toArray(new String[0])); } current = Long.parseLong(result.getCursor()); } while (!result.isCompleteIteration()); }
Example #3
Source File: AbstractBufferedJedisWriter.java From logback-redis with Apache License 2.0 | 6 votes |
private boolean sendValuesToRedis(String... values) { if (values.length == 0) { return true; } synchronized (client) { /* * RedisBatchAppender-doc stated, that jedis client is not thread safe. * logback's AppenderBase.doAppend is synchronized, so no concurrent logs can access this method, * but flushing thread could be active */ try { final Pipeline pipeline = client.getPipeline().orElse(null); if (pipeline != null) { final long start = System.currentTimeMillis(); addValuesToPipeline(pipeline, values); pipeline.sync(); logSendStatistics(values.length, start); return true; } } catch (JedisException ex) { log.info("unable to send {} events, reconnecting to redis", values.length, ex); } client.reconnect(); return false; } }
Example #4
Source File: Redis.java From AntiVPN with MIT License | 6 votes |
public void postMCLeaksRaw(long id, long longPlayerID, boolean value, long created) throws StorageException { try (Jedis redis = pool.getResource()) { JSONObject obj = new JSONObject(); obj.put("playerID", longPlayerID); obj.put("result", value); obj.put("created", created); redis.set(prefix + "mcleaks_values:" + id, obj.toJSONString()); obj.remove("playerID"); obj.put("id", id); redis.rpush(prefix + "mcleaks_values:player:" + longPlayerID, obj.toJSONString()); } catch (JedisException ex) { throw new StorageException(isAutomaticallyRecoverable(ex), ex); } }
Example #5
Source File: JedisAutoConfiguration.java From super-cloudops with Apache License 2.0 | 6 votes |
public synchronized Set<HostAndPort> parseHostAndPort() throws Exception { try { Set<HostAndPort> haps = new HashSet<HostAndPort>(); for (String node : this.getNodes()) { boolean matched = DefaultNodePattern.matcher(node).matches(); if (!matched) { throw new IllegalArgumentException("illegal ip or port"); } String[] addrString = node.split(":"); HostAndPort hap = new HostAndPort(addrString[0].trim(), Integer.parseInt(addrString[1])); if (log.isDebugEnabled()) { log.debug("Redis node: {}", hap); } haps.add(hap); } return haps; } catch (Exception e) { throw new JedisException("Resolve of redis cluster configuration failure.", e); } }
Example #6
Source File: JedisMock.java From conductor with Apache License 2.0 | 6 votes |
@Override public Long zadd(final String key, final Map<String, Double> scoreMembers) { try { Double score = null; String member = null; List<ZsetPair> scoresmembers = new ArrayList<ZsetPair>((scoreMembers.size() - 1)*2); for (String m : scoreMembers.keySet()) { if (m == null) { member = m; score = scoreMembers.get(m); continue; } scoresmembers.add(new ZsetPair(m, scoreMembers.get(m))); } return redis.zadd(key, new ZsetPair(member, score), (ZsetPair[])scoresmembers.toArray()); } catch (Exception e) { throw new JedisException(e); } }
Example #7
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long lrem(final String key, final long count, final String value) { try { return redis.lrem(key, count, value); } catch (Exception e) { throw new JedisException(e); } }
Example #8
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long append(final String key, final String value) { try { return redis.append(key, value); } catch (Exception e) { throw new JedisException(e); } }
Example #9
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long zadd(final String key, final double score, final String member) { try { return redis.zadd(key, new ZsetPair(member, score)); } catch (Exception e) { throw new JedisException(e); } }
Example #10
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long del(String key) { try { return redis.del(key); } catch (Exception e) { throw new JedisException(e); } }
Example #11
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Double hincrByFloat(final String key, final String field, final double value) { try { return Double.parseDouble(redis.hincrbyfloat(key, field, value)); } catch (Exception e) { throw new JedisException(e); } }
Example #12
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(final String key, final String min, final String max) { try { return toTupleSet(redis.zrangebyscore(key, min, max, "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #13
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(final String key, final double min, final double max, final int offset, final int count) { try { return toTupleSet(redis.zrangebyscore(key, String.valueOf(min), String.valueOf(max), "limit", String.valueOf(offset), String.valueOf(count), "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #14
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<String> zrevrangeByScore(final String key, final double max, final double min, final int offset, final int count) { try { return ZsetPair.members(redis.zrevrangebyscore(key, String.valueOf(max), String.valueOf(min), "limit", String.valueOf(offset), String.valueOf(count))); } catch (Exception e) { throw new JedisException(e); } }
Example #15
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long incr(final String key) { try { return redis.incr(key); } catch (Exception e) { throw new JedisException(e); } }
Example #16
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long sinterstore(final String dstkey, final String... keys) { try { String key = keys[0]; String[] k = new String[keys.length - 1]; for (int idx = 0; idx < keys.length; ++idx) { k[idx - 1] = keys[idx]; } return redis.sinterstore(dstkey, key, k); } catch (Exception e) { throw new JedisException(e); } }
Example #17
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Map<String, String> hgetAll(final String key) { try { return redis.hgetall(key); } catch (Exception e) { throw new JedisException(e); } }
Example #18
Source File: SafeEncoder.java From cachecloud with Apache License 2.0 | 5 votes |
public static byte[] encode(final String str) { try { if (str == null) { throw new JedisDataException("value sent to redis cannot be null"); } return str.getBytes(Protocol.CHARSET); } catch (UnsupportedEncodingException e) { throw new JedisException(e); } }
Example #19
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeWithScores(final String key, final long start, final long end) { try { return toTupleSet(redis.zrevrange(key, start, end, "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #20
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long zrem(final String key, final String... members) { try { String member = members[0]; String[] ms = new String[members.length - 1]; for (int idx = 1; idx < members.length; ++idx) { ms[idx - 1] = members[idx]; } return redis.zrem(key, member, ms); } catch (Exception e) { throw new JedisException(e); } }
Example #21
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(final String key, final String max, final String min) { try { return toTupleSet(redis.zrevrangebyscore(key, max, min, "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #22
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<String> zrevrangeByScore(final String key, final String max, final String min, final int offset, final int count) { try { return ZsetPair.members(redis.zrevrangebyscore(key, max, min, "limit", String.valueOf(offset), String.valueOf(count))); } catch (Exception e) { throw new JedisException(e); } }
Example #23
Source File: CloudDB.java From appinventor-extensions with Apache License 2.0 | 5 votes |
public Object jEval(String script, String scriptsha1, int argcount, String... args) throws JedisException { Jedis jedis = getJedis(); try { return jedis.evalsha(scriptsha1, argcount, args); } catch (JedisNoScriptException e) { if (DEBUG) { Log.d(LOG_TAG, "Got a JedisNoScriptException for " + scriptsha1); } // This happens if the server doesn't have the script loaded // So we use regular eval, which should then cache the script return jedis.eval(script, argcount, args); } }
Example #24
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
public ScanResult<Tuple> zscan(final String key, final String cursor) { try { org.rarefiedredis.redis.ScanResult<Set<ZsetPair>> sr = redis.zscan(key, Long.valueOf(cursor), "count", "1000000"); List<ZsetPair> list = sr.results.stream().collect(Collectors.toList()); List<Tuple> tl = new LinkedList<Tuple>(); list.forEach(p -> tl.add(new Tuple(p.member, p.score))); ScanResult<Tuple> result = new ScanResult<Tuple>("0", tl); return result; } catch (Exception e) { throw new JedisException(e); } }
Example #25
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Long sinterstore(final String dstkey, final String... keys) { try { String key = keys[0]; String[] k = new String[keys.length - 1]; for (int idx = 0; idx < keys.length; ++idx) { k[idx - 1] = keys[idx]; } return redis.sinterstore(dstkey, key, k); } catch (Exception e) { throw new JedisException(e); } }
Example #26
Source File: JedisUtils.java From easyweb with Apache License 2.0 | 5 votes |
/** * 获取资源 * @return * @throws JedisException */ public static Jedis getResource() throws JedisException { Jedis jedis = null; try { jedis = jedisPool.getResource(); // logger.debug("getResource.", jedis); } catch (JedisException e) { logger.warn("getResource.", e); returnBrokenResource(jedis); throw e; } return jedis; }
Example #27
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Boolean hexists(final String key, final String field) { try { return redis.hexists(key, field); } catch (Exception e) { throw new JedisException(e); } }
Example #28
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<String> hkeys(final String key) { try { return redis.hkeys(key); } catch (Exception e) { throw new JedisException(e); } }
Example #29
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public String lset(final String key, final long index, final String value) { try { return redis.lset(key, index, value); } catch (Exception e) { throw new JedisException(e); } }
Example #30
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Double incrByFloat(final String key, final double value) { try { return Double.parseDouble(redis.incrbyfloat(key, value)); } catch (Exception e) { throw new JedisException(e); } }