Java Code Examples for org.redisson.api.RList#add()
The following examples show how to use
org.redisson.api.RList#add() .
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: RedissonInstrumentationTest.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Test void testList() { try (Scope scope = tracer.startRootTransaction(getClass().getClassLoader()).withName("transaction").activateInScope()) { RList<String> strings = redisson.getList("list1"); strings.add("a"); assertThat(strings.size()).isEqualTo(1); assertThat(strings.get(0)).isEqualTo("a"); } assertTransactionWithRedisSpans("RPUSH", "LLEN", "LINDEX"); }
Example 2
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 5 votes |
@Override public void addJob(JobInfo jobInfo) { RMap<String, JobInfo> map = redissonClient.getMap(Container.JOB_INFO); jobInfo.setId(UUID.randomUUID().toString()); RList<String> sortList = redissonClient.getList(Container.JOB_INFO_SORT); sortList.add(jobInfo.getId()); // script if (JobInfo.TYPE.SCRIPT.name().equals(jobInfo.getType())) { JobScript script = build(jobInfo); redissonClient.<String, JobScript>getListMultimap(Container.JOB_INFO_SCRIPT) .put(jobInfo.getId(), script); } jobInfo.setScript(null); map.put(jobInfo.getId(), jobInfo); }
Example 3
Source File: TracingRedissonTest.java From java-redis-client with Apache License 2.0 | 5 votes |
@Test public void test_list() { RList<Object> list = client.getList("list"); list.add("key"); assertTrue(list.contains("key")); List<MockSpan> spans = tracer.finishedSpans(); assertEquals(2, spans.size()); checkSpans(spans); assertNull(tracer.activeSpan()); }
Example 4
Source File: RedisPlayground.java From synapse with Apache License 2.0 | 5 votes |
@Test public void shouldRetrieveMessagesByPosition() { RList<String> list = redisson.getList("test-list"); for (int i = 0; i < 10; i++) { list.add("message-" + i); } list.listIterator(5).forEachRemaining((m) -> { LOG.info("Received message={}", m); }); }
Example 5
Source File: RedisPlayground.java From synapse with Apache License 2.0 | 5 votes |
public void shouldBuildReallyLargeList() { RList<String> list = redisson.getList("test-list"); for (int i = 0; i < 1000000; i++) { list.add("message-" + i); } list.listIterator(999995).forEachRemaining((m) -> { LOG.info("Received message={}", m); }); }
Example 6
Source File: ListExamples.java From redisson-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RList<String> list = redisson.getList("myList"); list.add("1"); list.add("2"); list.add("3"); list.contains("1"); String valueAtIndex = list.get(3); for (String string : list) { // iteration through bulk loaded values } boolean removedValue = list.remove("1"); list.removeAll(Arrays.asList("1", "2", "3")); list.containsAll(Arrays.asList("4", "1", "0")); List<String> secondList = new ArrayList<>(); secondList.add("4"); secondList.add("5"); list.addAll(secondList); // fetch all objects List<String> allValues = list.readAll(); list.addAfter("3", "7"); list.addBefore("4", "6"); // use fast* methods when previous value is not required list.fastSet(1, "6"); list.fastRemove(3); redisson.shutdown(); }
Example 7
Source File: RedissonCollectionMapReduceTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testInjector() { RList<String> list = getCollection(); list.add("Alice was beginning to get very tired"); RCollectionMapReduce<String, String, Integer> mapReduce = list.<String, Integer>mapReduce().mapper(new WordMapperInject()).reducer(new WordReducerInject()); mapReduce.execute(); assertThat(redisson.getAtomicLong("test").get()).isEqualTo(8); mapReduce.execute(new WordCollatorInject()); assertThat(redisson.getAtomicLong("test").get()).isEqualTo(16 + 1); }
Example 8
Source File: RedissonCollectionMapReduceTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void test() { RList<String> list = getCollection(); list.add("Alice was beginning to get very tired"); list.add("of sitting by her sister on the bank and"); list.add("of having nothing to do once or twice she"); list.add("had peeped into the book her sister was reading"); list.add("but it had no pictures or conversations in it"); list.add("and what is the use of a book"); list.add("thought Alice without pictures or conversation"); Map<String, Integer> result = new HashMap<>(); result.put("to", 2); result.put("Alice", 2); result.put("get", 1); result.put("beginning", 1); result.put("sitting", 1); result.put("do", 1); result.put("by", 1); result.put("or", 3); result.put("into", 1); result.put("sister", 2); result.put("on", 1); result.put("a", 1); result.put("without", 1); result.put("and", 2); result.put("once", 1); result.put("twice", 1); result.put("she", 1); result.put("had", 2); result.put("reading", 1); result.put("but", 1); result.put("it", 2); result.put("no", 1); result.put("in", 1); result.put("what", 1); result.put("use", 1); result.put("thought", 1); result.put("conversation", 1); result.put("was", 2); result.put("very", 1); result.put("tired", 1); result.put("of", 3); result.put("her", 2); result.put("the", 3); result.put("bank", 1); result.put("having", 1); result.put("nothing", 1); result.put("peeped", 1); result.put("book", 2); result.put("pictures", 2); result.put("conversations", 1); result.put("is", 1); RCollectionMapReduce<String, String, Integer> mapReduce = list.<String, Integer>mapReduce().mapper(new WordMapper()).reducer(new WordReducer()); assertThat(mapReduce.execute()).isEqualTo(result); Integer count = mapReduce.execute(new WordCollator()); assertThat(count).isEqualTo(57); mapReduce.execute("resultMap"); RMap<Object, Object> resultMap = redisson.getMap("resultMap"); assertThat(resultMap).isEqualTo(result); resultMap.delete(); }