/** * 装载面板数据. * * @param key 数据库中的键 */ @Override public void setValue(String key) { ObservableList<TableEntity> values = FXCollections.observableArrayList(); Set<Tuple> sets = redisZset.getMemberSetWithScore(key); int i = 0; for (Tuple set : sets) { TableEntity value = new TableEntity("" + i, set.getElement(), "" + set.getScore()); values.add(value); i++; } this.dataTable.setItems(values); this.rowColumn.setCellValueFactory(cellData -> cellData.getValue().rowProperty()); this.keyColumn.setCellValueFactory(cellData -> cellData.getValue().keyProperty()); this.valueColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty()); }
public List<CrossRank> queryRank(int rankType, int start, int end) { List<CrossRank> ranks = new ArrayList<>(); Set<Tuple> tupleSet = cluster.zrevrangeWithScores("CrossRank_" + rankType, start , end ); Class<? extends AbstractCrossRank> rankClazz = rank2Class.get(rankType); for (Tuple record:tupleSet) { try{ String element = record.getElement(); AbstractCrossRank rankProto = rankClazz.newInstance(); String resultKey = rankProto.buildResultKey(); String data = cluster.hget(resultKey, element); CrossRank rank = unserialize(data, rankClazz); ranks.add(rank); }catch(Exception e) { e.printStackTrace(); } } return ranks; }
/** * 获取所有成员及分数 * * @param key */ public Set<Tuple> zAllMemberWithScore(String key) { Jedis jedis = null; boolean success = true; Set<Tuple> set = null; try { jedis = jedisPool.getResource(); if (jedis == null) { success = false; return set; } set = jedis.zrevrangeWithScores(key, 0, -1); } catch (Exception e) { success = false; releaseBrokenReidsSource(jedis, key, "zAllMemberWithScore", e, false); } finally { releaseReidsSource(success, jedis); } return set; }
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrevrangeByScoreWithScores(key, max, min); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Test public void zscan() { jedis.zadd("foo", 1, "a"); jedis.zadd("foo", 2, "b"); ScanResult<Tuple> result = jedis.zscan("foo", SCAN_POINTER_START); assertEquals(SCAN_POINTER_START, result.getStringCursor()); assertFalse(result.getResult().isEmpty()); // binary jedis.zadd(bfoo, 1, ba); jedis.zadd(bfoo, 1, bb); ScanResult<Tuple> bResult = jedis.zscan(bfoo, SCAN_POINTER_START_BINARY); assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes()); assertFalse(bResult.getResult().isEmpty()); }
private Pager<Integer> getIdsByRedis(String key,double max,double min, int offset, int row) { Pager<Integer> pager = new Pager<Integer>(); List<Integer> lists = new ArrayList<Integer>(); Jedis redis = jedisPool.getResource(); Set<Tuple> setCount = redis.zrevrangeByScoreWithScores(key, max, min); int count = setCount.size(); pager.setRows(count); if(count <= 0) return pager; Set<Tuple> set = redis.zrevrangeByScoreWithScores(key, max, min, offset, row); Iterator<Tuple> it = set.iterator(); Tuple t =null; while (it.hasNext()) { t = it.next(); lists.add(Integer.parseInt(t.getElement())); } pager.setResult(lists); return pager; }
@Override public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrangeByScoreWithScores(key, min, max, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrangeByScoreWithScores(key, min, max, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max, int offset, int count) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", Arrays.toString(min)); span.setTag("max", Arrays.toString(max)); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrangeByScoreWithScores(key, min, max, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max, int offset, int count) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrangeByScoreWithScores(key, min, max, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
private void show(){ Set<Tuple> sets = redisSortSet.getMemberSetWithScore(key); for(Tuple k:sets){ System.out.println(k.getElement()+" : "+k.getScore()); } redisSortSet.deleteKey(key); }
@Override public ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params) { Span span = helper.buildSpan("zscan", key); span.setTag("cursor", Arrays.toString(cursor)); span.setTag("params", TracingHelper.toString(params.getParams())); try { return super.zscan(key, cursor, params); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public ScanResult<Tuple> zscan(String key, int cursor) { Span span = helper.buildSpan("zscan", key); span.setTag("cursor", cursor); try { return super.zscan(key, cursor); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrangeByScoreWithScores(key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
/** * zrevrangeByScoreWithScores * * @param key specified key * @param max max value * @param min min value * @return Multi bulk reply specifically a list of elements in the specified score range. */ @Override public Set<Tuple> zrevrangeByScoreWithScores(final String bizkey,final String nameSpace, final double max, final double min) { final String key = CacheUtils.getKeyByNamespace(bizkey,nameSpace); return this.performFunction(key, new CallBack<Set<Tuple>>() { public Set<Tuple> invoke(Jedis jedis) { return jedis.zrevrangeByScoreWithScores(key, max, min); } }); }
/** * zrevrangeByScoreWithScores * * @param key specified key * @param max max value * @param min min value * @param offset offset value * @param count count number * @return Multi bulk reply specifically a list of elements in the specified score range. */ @Override public Set<Tuple> zrevrangeByScoreWithScores(final String bizkey,final String nameSpace, final double max, final double min, final int offset, final int count) { final String key = CacheUtils.getKeyByNamespace(bizkey,nameSpace); return this.performFunction(key, new CallBack<Set<Tuple>>() { public Set<Tuple> invoke(Jedis jedis) { return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); } }); }
@Override public Set<Tuple> zrevrangeWithScores(String key, long start, long end) { Span span = helper.buildSpan("zrevrangeWithScores", key); span.setTag("start", start); span.setTag("end", end); try { return super.zrevrangeWithScores(key, start, end); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
public static final Set<Tuple> zrevrangeWithScores(final String key, final int start, final int end) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrevrangeWithScores(key, start, end); } }); }
public static final Set<Tuple> zrevrangeByScoreWithScores(final String key, final double max, final double min) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrevrangeByScoreWithScores(key, max, min); } }); }
public static final Set<Tuple> zrangeByScoreWithScores(final String key, final double min, final double max, final int offset, final int count) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrangeByScoreWithScores(key, min, max, offset, count); } }); }
@Override public ScanResult<Tuple> zscan(String key, String cursor) { Span span = helper.buildSpan("zscan", key); span.setTag("cursor", cursor); try { return super.zscan(key, cursor); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
public static final Set<Tuple> zrangeWithScores(final byte[] key, final int start, final int end) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrangeWithScores(key, start, end); } }); }
public static final Set<Tuple> zrevrangeWithScores(final byte[] key, final int start, final int end) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrevrangeWithScores(key, start, end); } }); }
public static final Set<Tuple> zrangeByScoreWithScores(final byte[] key, final double min, final double max, final int offset, final int count) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrangeByScoreWithScores(key, min, max, offset, count); } }); }
public static final Set<Tuple> zrevrangeByScoreWithScores(final byte[] key, final double max, final double min, final int offset, final int count) { return JedisTemplate.run(key, new Executor<Set<Tuple>>() { public Set<Tuple> execute(ShardedJedis jedis) { return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); } }); }
/** * zrangeWithScores * @param key specified key * @param start start * @param end end * @return zrangeWithScores Set */ @Override public Set<Tuple> zrangeWithScores(final String key, final long start, final long end) { return this.performFunction(key, new CallBack<Set<Tuple>>() { /** * invoke * @param jedis jedis * @return invoke results */ public Set<Tuple> invoke(Jedis jedis) { return jedis.zrangeWithScores(key, start, end); } }); }
@Override public ScanResult<Tuple> zscan(String key, String cursor, ScanParams params) { Span span = helper.buildSpan("zscan", key); span.setTag("cursor", cursor); span.setTag("params", TracingHelper.toString(params.getParams())); try { return super.zscan(key, cursor, params); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", Arrays.toString(min)); span.setTag("max", Arrays.toString(max)); try { return super.zrangeByScoreWithScores(key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
/** * zrevrangeByScoreWithScores * @param key specified key * @param max max * @param min min * @param offset offset * @param count count * @return Multi bulk reply */ @Override public Set<Tuple> zrevrangeByScoreWithScores(final String key, final double max, final double min, final int offset, final int count) { return this.performFunction(key, new CallBack<Set<Tuple>>() { /** * invoke * @param jedis jedis * @return invoke results */ public Set<Tuple> invoke(Jedis jedis) { return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); } }); }
@Override public ScanResult<Tuple> zscan(byte[] key, byte[] cursor) { Span span = helper.buildSpan("zscan", key); span.setTag("cursor", Arrays.toString(cursor)); try { return super.zscan(key, cursor); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
/** * zrangeWithScores * * @param key specified key * @param start specified member * @param end specified member * @return Multi bulk reply specifically a list of elements in the specified range. */ @Override public Set<Tuple> zrangeWithScores(final String key, final long start, final long end) { return this.performFunction(key, new CallBack<Set<Tuple>>() { public Set<Tuple> invoke(Jedis jedis) { return jedis.zrangeWithScores(key, start, end); } }); }
@Override public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrangeByScoreWithScores(key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
/** * zrevrangeByScoreWithScores * * @param key specified key * @param max max value * @param min min value * @return Multi bulk reply specifically a list of elements in the specified score range. */ @Override public Set<Tuple> zrevrangeByScoreWithScores(final String key, final double max, final double min) { return this.performFunction(key, new CallBack<Set<Tuple>>() { public Set<Tuple> invoke(Jedis jedis) { return jedis.zrevrangeByScoreWithScores(key, max, min); } }); }