org.redisson.api.RScoredSortedSet Java Examples
The following examples show how to use
org.redisson.api.RScoredSortedSet.
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: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortTo() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE); set.add(10, 1); set.add(9, 2); set.add(8, 3); assertThat(set.sortTo("test3", SortOrder.DESC)).isEqualTo(3); RList<String> list2 = redisson.getList("test3", StringCodec.INSTANCE); assertThat(list2).containsExactly("3", "2", "1"); assertThat(set.sortTo("test4", SortOrder.ASC)).isEqualTo(3); RList<String> list3 = redisson.getList("test4", StringCodec.INSTANCE); assertThat(list3).containsExactly("1", "2", "3"); }
Example #2
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPattern() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE); set.add(10, 1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(3); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1); Set<Integer> descSort = set.readSort("test*", SortOrder.DESC); assertThat(descSort).containsExactly(1, 2, 3); Set<Integer> ascSort = set.readSort("test*", SortOrder.ASC); assertThat(ascSort).containsExactly(3, 2, 1); }
Example #3
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testIntersectionWithWeight() { RScoredSortedSet<String> set1 = redisson.getScoredSortedSet("simple1"); set1.add(1, "one"); set1.add(2, "two"); RScoredSortedSet<String> set2 = redisson.getScoredSortedSet("simple2"); set2.add(1, "one"); set2.add(2, "two"); set2.add(3, "three"); RScoredSortedSet<String> out = redisson.getScoredSortedSet("out"); Map<String, Double> nameWithWeight = new HashMap<>(); nameWithWeight.put(set1.getName(), 2D); nameWithWeight.put(set2.getName(), 3D); assertThat(out.intersection(nameWithWeight)).isEqualTo(2); assertThat(out.readAll()).containsOnly("one", "two"); assertThat(out.getScore("one")).isEqualTo(5); assertThat(out.getScore("two")).isEqualTo(10); }
Example #4
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPatternGet() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", StringCodec.INSTANCE); set.add(10, 1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(1); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(3); redisson.getBucket("tester1", StringCodec.INSTANCE).set("obj1"); redisson.getBucket("tester2", StringCodec.INSTANCE).set("obj2"); redisson.getBucket("tester3", StringCodec.INSTANCE).set("obj3"); Collection<String> descSort = set.readSort("test*", Arrays.asList("tester*"), SortOrder.DESC); assertThat(descSort).containsExactly("obj3", "obj2", "obj1"); Collection<String> ascSort = set.readSort("test*", Arrays.asList("tester*"), SortOrder.ASC); assertThat(ascSort).containsExactly("obj1", "obj2", "obj3"); }
Example #5
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPatternGetLimit() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", StringCodec.INSTANCE); set.add(10, 1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(1); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(3); redisson.getBucket("tester1", StringCodec.INSTANCE).set("obj1"); redisson.getBucket("tester2", StringCodec.INSTANCE).set("obj2"); redisson.getBucket("tester3", StringCodec.INSTANCE).set("obj3"); Collection<String> descSort = set.readSort("test*", Arrays.asList("tester*"), SortOrder.DESC, 1, 2); assertThat(descSort).containsExactly("obj2", "obj1"); Collection<String> ascSort = set.readSort("test*", Arrays.asList("tester*"), SortOrder.ASC, 1, 2); assertThat(ascSort).containsExactly("obj2", "obj3"); }
Example #6
Source File: RedissonInstrumentationTest.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Test void testSortedSet() { try (Scope scope = tracer.startRootTransaction(getClass().getClassLoader()).withName("transaction").activateInScope()) { Map<String, Double> scores = new HashMap<>(); scores.put("u1", 1.0d); scores.put("u2", 3.0d); scores.put("u3", 0.0d); RScoredSortedSet<String> sortSet = redisson.getScoredSortedSet("sort_set1"); sortSet.addAll(scores); assertThat(sortSet.rank("u1")).isEqualTo(1); assertThat(sortSet.rank("u3")).isEqualTo(0); } assertTransactionWithRedisSpans("ZADD", "ZRANK", "ZRANK"); }
Example #7
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testPollLastFromAny() throws InterruptedException { Assume.assumeTrue(RedisRunner.getDefaultRedisServerInstance().getRedisVersion().compareTo("5.0.0") > 0); final RScoredSortedSet<Integer> queue1 = redisson.getScoredSortedSet("queue:pollany"); Executors.newSingleThreadScheduledExecutor().schedule(() -> { RScoredSortedSet<Integer> queue2 = redisson.getScoredSortedSet("queue:pollany1"); RScoredSortedSet<Integer> queue3 = redisson.getScoredSortedSet("queue:pollany2"); queue3.add(0.1, 2); queue1.add(0.1, 1); queue2.add(0.1, 3); }, 3, TimeUnit.SECONDS); long s = System.currentTimeMillis(); int l = queue1.pollLastFromAny(4, TimeUnit.SECONDS, "queue:pollany1", "queue:pollany2"); Assert.assertEquals(2, l); Assert.assertTrue(System.currentTimeMillis() - s > 2000); }
Example #8
Source File: LiveObjectSearch.java From redisson with Apache License 2.0 | 6 votes |
private boolean checkValueRange(Set<Object> allIds, Map<RScoredSortedSet<Object>, Number> numericNames, BiFunction<RScoredSortedSet<Object>, Number, Collection<Object>> func) { if (numericNames.isEmpty()) { return true; } for (Entry<RScoredSortedSet<Object>, Number> e : numericNames.entrySet()) { Collection<Object> gtIds = func.apply(e.getKey(), e.getValue()); if (gtIds.isEmpty()) { return false; } if (!allIds.isEmpty()) { allIds.retainAll(gtIds); if (allIds.isEmpty()) { return false; } } else { allIds.addAll(gtIds); } } return true; }
Example #9
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testTakeFirst() { Assume.assumeTrue(RedisRunner.getDefaultRedisServerInstance().getRedisVersion().compareTo("5.0.0") > 0); final RScoredSortedSet<Integer> queue1 = redisson.getScoredSortedSet("queue:pollany"); Executors.newSingleThreadScheduledExecutor().schedule(() -> { RScoredSortedSet<Integer> queue2 = redisson.getScoredSortedSet("queue:pollany1"); RScoredSortedSet<Integer> queue3 = redisson.getScoredSortedSet("queue:pollany2"); queue1.add(0.1, 1); }, 3, TimeUnit.SECONDS); long s = System.currentTimeMillis(); int l = queue1.takeFirst(); Assert.assertEquals(1, l); Assert.assertTrue(System.currentTimeMillis() - s > 2000); }
Example #10
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testPollFirstFromAny() throws InterruptedException { Assume.assumeTrue(RedisRunner.getDefaultRedisServerInstance().getRedisVersion().compareTo("5.0.0") > 0); final RScoredSortedSet<Integer> queue1 = redisson.getScoredSortedSet("queue:pollany"); Executors.newSingleThreadScheduledExecutor().schedule(() -> { RScoredSortedSet<Integer> queue2 = redisson.getScoredSortedSet("queue:pollany1"); RScoredSortedSet<Integer> queue3 = redisson.getScoredSortedSet("queue:pollany2"); queue3.add(0.1, 2); queue1.add(0.1, 1); queue2.add(0.1, 3); }, 3, TimeUnit.SECONDS); long s = System.currentTimeMillis(); int l = queue1.pollFirstFromAny(4, TimeUnit.SECONDS, "queue:pollany1", "queue:pollany2"); Assert.assertEquals(2, l); Assert.assertTrue(System.currentTimeMillis() - s > 2000); }
Example #11
Source File: ProductSearchServiceImpl.java From gpmall with Apache License 2.0 | 6 votes |
/** * 统计搜索热词 * @param request request */ private void staticsSearchHotWord(SearchRequest request) { //搜索词 String keyword = request.getKeyword(); if(StringUtils.isNotEmpty(keyword)){ RScoredSortedSet<Object> scoredSortedSet = redissonClient.getScoredSortedSet(getSearchHotWordRedisKey()); Double score = scoredSortedSet.getScore(keyword); if(score!=null){ scoredSortedSet.addAndGetRank(score+1.0,keyword); }else{ scoredSortedSet.addScore(keyword,1); } } }
Example #12
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPatternAlpha(){ RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE); set.add(10,1); set.add(9,2); set.add(8,3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(12); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(3); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1); Collection<Integer> descSort = set .readSortAlpha("test*", SortOrder.DESC); assertThat(descSort).containsExactly(2, 1, 3); Collection<Integer> ascSort = set .readSortAlpha("test*", SortOrder.ASC); assertThat(ascSort).containsExactly(3, 1, 2); }
Example #13
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPatternAlphaLimit(){ RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE); set.add(10,1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(12); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(3); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1); Collection<Integer> descSort = set .readSortAlpha("test*", SortOrder.DESC,1,2); assertThat(descSort).containsExactly(1, 3); Collection<Integer> ascSort = set .readSortAlpha("test*", SortOrder.ASC,1,2); assertThat(ascSort).containsExactly(1, 2); }
Example #14
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPatternGetAlpha() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", StringCodec.INSTANCE); set.add(10,1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(12); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(3); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1); redisson.getBucket("tester1", StringCodec.INSTANCE).set("obj1"); redisson.getBucket("tester2", StringCodec.INSTANCE).set("obj2"); redisson.getBucket("tester3", StringCodec.INSTANCE).set("obj3"); Collection<String> descSort = set .readSortAlpha("test*", Arrays.asList("tester*"), SortOrder.DESC); assertThat(descSort).containsExactly("obj2", "obj1", "obj3"); Collection<String> ascSort = set .readSortAlpha("test*", Arrays.asList("tester*"), SortOrder.ASC); assertThat(ascSort).containsExactly("obj3", "obj1", "obj2"); }
Example #15
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortOrderByPatternGetAlphaLimit() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", StringCodec.INSTANCE); set.add(10,1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(12); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(3); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1); redisson.getBucket("tester1", StringCodec.INSTANCE).set("obj1"); redisson.getBucket("tester2", StringCodec.INSTANCE).set("obj2"); redisson.getBucket("tester3", StringCodec.INSTANCE).set("obj3"); Collection<String> descSort = set .readSortAlpha("test*", Arrays.asList("tester*"), SortOrder.DESC,1,2); assertThat(descSort).containsExactly("obj1", "obj3"); Collection<String> ascSort = set .readSortAlpha("test*", Arrays.asList("tester*"), SortOrder.ASC,1, 2); assertThat(ascSort).containsExactly("obj1", "obj2"); }
Example #16
Source File: ProductSearchServiceImpl.java From gpmall with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public SearchResponse hotProductKeyword() { //商品热门搜索关键字 //获取到分数第一的 搜索词 SearchResponse response = new SearchResponse(); try { RScoredSortedSet<Object> scoredSortedSet = redissonClient.getScoredSortedSet(getSearchHotWordRedisKey()); Object first = scoredSortedSet.first(); if(!Objects.isNull(first)){ response.ok(Collections.singletonList(first)); } }catch (Exception e){ e.printStackTrace(); log.error("ProductSearchServiceImpl.hotProductKeyword Occur Exception :" + e); ExceptionProcessorUtils.wrapperHandlerException(response,e); } return response; }
Example #17
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testSortToByPattern() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE); set.add(10, 1); set.add(9, 2); set.add(8, 3); redisson.getBucket("test1", IntegerCodec.INSTANCE).set(3); redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2); redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1); assertThat(set.sortTo("tester3", "test*", SortOrder.DESC, 1, 2)).isEqualTo(2); RList<String> list2 = redisson.getList("tester3", StringCodec.INSTANCE); assertThat(list2).containsExactly("2", "3"); assertThat(set.sortTo("tester4", "test*", SortOrder.ASC, 1, 2)).isEqualTo(2); RList<String> list3 = redisson.getList("tester4", StringCodec.INSTANCE); assertThat(list3).containsExactly("2", "1"); }
Example #18
Source File: RedisUtils.java From geowave with Apache License 2.0 | 6 votes |
public static RScoredSortedSet<GeoWaveMetadata> getMetadataSet( final RedissonClient client, final Compression compression, final String namespace, final MetadataType metadataType, final boolean visibilityEnabled) { // stats also store a timestamp because stats can be the exact same but // need to still be unique (consider multiple count statistics that are // exactly the same count, but need to be merged) return client.getScoredSortedSet( namespace + "_" + metadataType.toString(), compression.getCodec( MetadataType.STATS.equals(metadataType) ? visibilityEnabled ? GeoWaveMetadataWithTimestampCodec.SINGLETON_WITH_VISIBILITY : GeoWaveMetadataWithTimestampCodec.SINGLETON_WITHOUT_VISIBILITY : visibilityEnabled ? GeoWaveMetadataCodec.SINGLETON_WITH_VISIBILITY : GeoWaveMetadataCodec.SINGLETON_WITHOUT_VISIBILITY)); }
Example #19
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testRemoveAsync() throws InterruptedException, ExecutionException { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("simple"); set.add(0.11, 1); set.add(0.22, 3); set.add(0.33, 7); Assert.assertTrue(set.removeAsync(1).get()); Assert.assertFalse(set.contains(1)); assertThat(set).containsExactly(3, 7); Assert.assertFalse(set.removeAsync(1).get()); assertThat(set).containsExactly(3, 7); set.removeAsync(3).get(); Assert.assertFalse(set.contains(3)); assertThat(set).containsExactly(7); }
Example #20
Source File: RedisScoredSetWrapper.java From geowave with Apache License 2.0 | 6 votes |
public Iterator<ScoredEntry<V>> entryRange( final double startScore, final boolean startScoreInclusive, final double endScore, final boolean endScoreInclusive) { final RScoredSortedSet<V> currentSet = getCurrentSyncCollection(); final Collection<ScoredEntry<V>> currentResult = currentSet.entryRange( startScore, startScoreInclusive, endScore, endScoreInclusive, 0, RedisUtils.MAX_ROWS_FOR_PAGINATION); if (currentResult.size() >= RedisUtils.MAX_ROWS_FOR_PAGINATION) { return new LazyPaginatedEntryRange<>( startScore, startScoreInclusive, endScore, endScoreInclusive, currentSet, currentResult); } return currentResult.iterator(); }
Example #21
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testUnion() { RScoredSortedSet<String> set1 = redisson.getScoredSortedSet("simple1"); set1.add(1, "one"); set1.add(2, "two"); RScoredSortedSet<String> set2 = redisson.getScoredSortedSet("simple2"); set2.add(1, "one"); set2.add(2, "two"); set2.add(3, "three"); RScoredSortedSet<String> out = redisson.getScoredSortedSet("out"); assertThat(out.union(set1.getName(), set2.getName())).isEqualTo(3); assertThat(out.readAll()).containsOnly("one", "two", "three"); assertThat(out.getScore("one")).isEqualTo(2); assertThat(out.getScore("two")).isEqualTo(4); assertThat(out.getScore("three")).isEqualTo(3); }
Example #22
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testUnionWithWeight() { RScoredSortedSet<String> set1 = redisson.getScoredSortedSet("simple1"); set1.add(1, "one"); set1.add(2, "two"); RScoredSortedSet<String> set2 = redisson.getScoredSortedSet("simple2"); set2.add(1, "one"); set2.add(2, "two"); set2.add(3, "three"); RScoredSortedSet<String> out = redisson.getScoredSortedSet("out"); Map<String, Double> nameWithWeight = new HashMap<>(); nameWithWeight.put(set1.getName(), 2D); nameWithWeight.put(set2.getName(), 3D); assertThat(out.union(nameWithWeight)).isEqualTo(3); assertThat(out.readAll()).containsOnly("one", "two", "three"); assertThat(out.getScore("one")).isEqualTo(5); assertThat(out.getScore("two")).isEqualTo(10); assertThat(out.getScore("three")).isEqualTo(9); }
Example #23
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testEntryRangeReversed() { RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("simple"); set.add(10, 1); set.add(20, 2); set.add(30, 3); set.add(40, 4); set.add(50, 5); Collection<ScoredEntry<Integer>> vals = set.entryRangeReversed(0, -1); assertThat(vals).containsExactly( new ScoredEntry<Integer>(50D, 5), new ScoredEntry<Integer>(40D, 4), new ScoredEntry<Integer>(30D, 3), new ScoredEntry<Integer>(20D, 2), new ScoredEntry<Integer>(10D, 1) ); }
Example #24
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testScoredSortedSetEntryRange() { RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple"); set.add(0, "a"); set.add(1, "b"); set.add(2, "c"); set.add(3, "d"); set.add(4, "e"); Collection<ScoredEntry<String>> r = set.entryRange(1, true, 4, false, 1, 2); Assert.assertEquals(2, r.size()); ScoredEntry<String>[] a = r.toArray(new ScoredEntry[0]); Assert.assertEquals(2d, a[0].getScore(), 0); Assert.assertEquals(3d, a[1].getScore(), 0); Assert.assertEquals("c", a[0].getValue()); Assert.assertEquals("d", a[1].getValue()); }
Example #25
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testScoredSortedSetEntryRangeReversed() { RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple"); set.add(0, "a"); set.add(1, "b"); set.add(2, "c"); set.add(3, "d"); set.add(4, "e"); Collection<ScoredEntry<String>> r = set.entryRangeReversed(1, true, 4, false, 1, 2); Assert.assertEquals(2, r.size()); ScoredEntry<String>[] a = r.toArray(new ScoredEntry[0]); Assert.assertEquals(2d, a[0].getScore(), 0); Assert.assertEquals(1d, a[1].getScore(), 0); Assert.assertEquals("c", a[0].getValue()); Assert.assertEquals("b", a[1].getValue()); }
Example #26
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testScoredSortedSetEntryRangeNegativeInf() { RScoredSortedSet<String> set = redisson.<String>getScoredSortedSet("simple"); set.add(0, "a"); set.add(1, "b"); set.add(2, "c"); set.add(3, "d"); set.add(4, "e"); Collection<ScoredEntry<String>> r = set.entryRange(Double.NEGATIVE_INFINITY, true, 4, false, 1, 2); ScoredEntry<String>[] a = r.toArray(new ScoredEntry[0]); Assert.assertEquals(1d, a[0].getScore(), 0); Assert.assertEquals(2d, a[1].getScore(), 0); Assert.assertEquals("b", a[0].getValue()); Assert.assertEquals("c", a[1].getValue()); }
Example #27
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testScoredSortedSetEntryRangePositiveInf() { RScoredSortedSet<String> set = redisson.<String>getScoredSortedSet("simple"); set.add(0, "a"); set.add(1, "b"); set.add(2, "c"); set.add(3, "d"); set.add(4, "e"); Collection<ScoredEntry<String>> r = set.entryRange(1, true, Double.POSITIVE_INFINITY, false, 1, 2); ScoredEntry<String>[] a = r.toArray(new ScoredEntry[0]); Assert.assertEquals(2d, a[0].getScore(), 0); Assert.assertEquals(3d, a[1].getScore(), 0); Assert.assertEquals("c", a[0].getValue()); Assert.assertEquals("d", a[1].getValue()); }
Example #28
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testAddAndGet() throws InterruptedException { RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple"); set.add(1, "100"); Double res = set.addScore("100", 11); Assert.assertEquals(12, (double)res, 0); Double score = set.getScore("100"); Assert.assertEquals(12, (double)score, 0); RScoredSortedSet<String> set2 = redisson.getScoredSortedSet("simple"); set2.add(100.2, "1"); Double res2 = set2.addScore("1", new Double(12.1)); Assert.assertTrue(new Double(112.3).compareTo(res2) == 0); res2 = set2.getScore("1"); Assert.assertTrue(new Double(112.3).compareTo(res2) == 0); }
Example #29
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testAddScoreAndGetRank() throws InterruptedException { RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple"); Integer res1 = set.addScoreAndGetRank("12", 12); assertThat(res1).isEqualTo(0); Integer res2 = set.addScoreAndGetRank("15", 10); assertThat(res2).isEqualTo(0); assertThat(set.rank("12")).isEqualTo(1); assertThat(set.rank("15")).isEqualTo(0); Integer res3 = set.addScoreAndGetRank("12", 2); assertThat(res3).isEqualTo(1); Double score = set.getScore("12"); assertThat(score).isEqualTo(14); }
Example #30
Source File: RedissonScoredSortedSetTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testAddScoreAndGetRevRank() throws InterruptedException { RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple"); Integer res1 = set.addScoreAndGetRevRank("12", 12); assertThat(res1).isEqualTo(0); Integer res2 = set.addScoreAndGetRevRank("15", 10); assertThat(res2).isEqualTo(1); assertThat(set.revRank("12")).isEqualTo(0); assertThat(set.revRank("15")).isEqualTo(1); Integer res3 = set.addScoreAndGetRevRank("12", 2); assertThat(res3).isEqualTo(0); Integer res4 = set.addScoreAndGetRevRank("15", -1); assertThat(res4).isEqualTo(1); Double score = set.getScore("12"); assertThat(score).isEqualTo(14); }