org.springframework.data.redis.core.BoundListOperations Java Examples
The following examples show how to use
org.springframework.data.redis.core.BoundListOperations.
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: StudentServiceImpl.java From spring-boot-cookbook with Apache License 2.0 | 6 votes |
@Override public ResultData<List<StudentDO>> listAll(Boolean hasError, Integer pageId, Integer pageSize) { BoundListOperations<String, Object> boundListOps = redisTemplate.boundListOps(STUDENT_LIST); List doList; int fromIndex = pageId * pageSize; int toIndex = fromIndex + pageSize; if (redisTemplate.hasKey(STUDENT_LIST)) { doList= boundListOps.range(fromIndex, toIndex-1); } else { List<StudentDO> all = studentRepository.listAll(); for (StudentDO studentDO : all) { boundListOps.leftPush(studentDO); } Collections.reverse(all); doList= PageTool.create(all,pageSize).get(pageId); } if (hasError) { throw new IllegalArgumentException("error.roll back"); } return ResultData.<List<StudentDO>>builder().detail(doList).build(); }
Example #2
Source File: RedisReadyQueue.java From Milkomeda with MIT License | 5 votes |
@Override public DelayJob pop(String topic) { BoundListOperations<String, String> listOperations = getQueue(topic); String delayJob = listOperations.leftPop(); if (null == delayJob) return null; return DelayJob.compatibleDecode(delayJob, null); }
Example #3
Source File: CartTest.java From Project with Apache License 2.0 | 5 votes |
@Test public void bindingToAKey() { Product product = new Product(); product.setSku("9781617291203"); product.setName("Spring in Action"); product.setPrice(39.99f); Product product2 = new Product(); product2.setSku("9781935182436"); product2.setName("Spring Integration in Action"); product2.setPrice(49.99f); Product product3 = new Product(); product3.setSku("9781935182955"); product3.setName("Spring Batch in Action"); product3.setPrice(49.99f); BoundListOperations<String, Product> cart = redis.boundListOps("cart"); cart.rightPush(product); cart.rightPush(product2); cart.rightPush(product3); assertEquals(3, cart.size().longValue()); Product first = cart.leftPop(); Product last = cart.rightPop(); assertEquals(product.getSku(), first.getSku()); assertEquals(product.getName(), first.getName()); assertEquals(product.getPrice(), first.getPrice(), 0.005); assertEquals(product3.getSku(), last.getSku()); assertEquals(product3.getName(), last.getName()); assertEquals(product3.getPrice(), last.getPrice(), 0.005); assertEquals(1, cart.size().longValue()); }
Example #4
Source File: RedisDemo.java From spring-boot-cookbook with Apache License 2.0 | 5 votes |
@Transactional(rollbackFor = {NullPointerException.class}) public void doBiz() { BoundListOperations<String, String> listOps = redisTemplate.boundListOps("myList"); listOps.leftPush("hello"); listOps.leftPush("world"); String value = getValue(); if (Objects.equals(value, "world")) { System.out.println("O,my god"); } }
Example #5
Source File: RedisReadyQueue.java From Milkomeda with MIT License | 4 votes |
@Override public void push(DelayJob delayJob) { BoundListOperations<String, String> listOperations = getQueue(delayJob.getTopic()); listOperations.rightPush(delayJob.toSimple()); }
Example #6
Source File: RedisReadyQueue.java From Milkomeda with MIT License | 4 votes |
private BoundListOperations<String, String> getQueue(String topic) { return redisTemplate.boundListOps(getKey(topic)); }
Example #7
Source File: MyRedisTemplate.java From redis-admin with Apache License 2.0 | 4 votes |
@Override public BoundListOperations<K, V> boundListOps(K key) { throw new MethodNotSupportException("myRedisTemplate not support this method : boundListOps(K key) , please use opsForXX"); //return new DefaultBoundListOperations<K, V>(key, this); }