org.springframework.data.redis.core.ListOperations Java Examples
The following examples show how to use
org.springframework.data.redis.core.ListOperations.
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: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 7 votes |
/** * 缓存list * * @param k key * @param v value * @param time time * @return boolean */ @Override public boolean cacheList(String k, List<String> v, long time) { String key = KEY_PREFIX_LIST + k; try { ListOperations<String, String> listOps = redisTemplate.opsForList(); listOps.rightPushAll(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } return true; } catch (Throwable t) { LOGGER.error("缓存[" + key + "]失败, value[" + v + "]", t); } return false; }
Example #2
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 6 votes |
public void setList(String k, List<T> v, long time) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); listOps.rightPushAll(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #3
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 6 votes |
public void setList(String k, T v, long time) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); listOps.rightPush(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #4
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 6 votes |
/** * list缓存 * * @param k key * @param v value * @param time time * @return boolean */ @Override public boolean cacheList(String k, String v, long time) { String key = KEY_PREFIX_LIST + k; try { ListOperations<String, String> listOps = redisTemplate.opsForList(); listOps.rightPush(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } return true; } catch (Throwable t) { LOGGER.error("缓存[" + key + "]失败, value[" + v + "]", t); } return false; }
Example #5
Source File: RedisMonitor.java From BootNettyRpc with Apache License 2.0 | 6 votes |
@Override public void execute(final MonitorMessage message) { ThreadPoolFactory.createThreadPoolDefaultExecutor().execute( new Runnable() { @Override public void run() { CommonProperties cp = nettyRpcProperties.getCommonProperties(); ListOperations<String, String> ops = stringRedisTemplate.opsForList(); ops.leftPush( message.getTraceId(), SerializerExecutor.toJson( message ) ); if (!cp.getMonitorRedisExpire().equals( "-1" )) { stringRedisTemplate.expire( message.getTraceId(), Long.parseLong( cp.getMonitorRedisExpire() ), getTimeUnit( cp.getMonitorRedisExpireTimeUnit() ) ); } } } ); }
Example #6
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public List<T> getList(String k, long start, long end) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); return listOps.range(key, start, end); } catch (Throwable t) { logger.error("getList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #7
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public long getListSize(ListOperations<String, String> listOps, String k) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("getListSize key [{}]", key); try { return listOps.size(key); } catch (Throwable t) { logger.error("getListSize key [{}] exception!", key, t); throw new CommonException(t); } }
Example #8
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public long getListSize(String k) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); return listOps.size(key); } catch (Throwable t) { logger.error("getListSize key [{}] exception!", key, t); throw new CommonException(t); } }
Example #9
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public List<T> getList(String k, long start, long end) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); return listOps.range(key, start, end); } catch (Throwable t) { logger.error("getList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #10
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setList(String k, T v, long time) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); listOps.rightPush(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #11
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public long getListSize(ListOperations<String, String> listOps, String k) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("getListSize key [{}]", key); try { return listOps.size(key); } catch (Throwable t) { logger.error("getListSize key [{}] exception!", key, t); throw new CommonException(t); } }
Example #12
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public long getListSize(String k) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); return listOps.size(key); } catch (Throwable t) { logger.error("getListSize key [{}] exception!", key, t); throw new CommonException(t); } }
Example #13
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public List<T> getList(String k, long start, long end) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); return listOps.range(key, start, end); } catch (Throwable t) { logger.error("getList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #14
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setList(String k, List<T> v, long time) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); listOps.rightPushAll(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #15
Source File: RedisSupport.java From mykit-delay with Apache License 2.0 | 5 votes |
public boolean lrem(String key, String value) { try { ListOperations<String, String> listOperations = template.opsForList(); listOperations.remove(key, 1, value); } catch (Exception e) { return false; } return true; }
Example #16
Source File: RedisServiceImpl.java From DouBiNovel with Apache License 2.0 | 5 votes |
@Override public Long remove(String key, Long count, Object value) { ListOperations<String, String> operations = this.template.opsForList(); if (this.exists(key)) { return operations.remove(key, count, value); } return null; }
Example #17
Source File: RedisCache.java From RuoYi-Vue with MIT License | 5 votes |
/** * 缓存List数据 * * @param key 缓存的键值 * @param dataList 待缓存的List数据 * @return 缓存的对象 */ public <T> ListOperations<String, T> setCacheList(String key, List<T> dataList) { ListOperations listOperation = redisTemplate.opsForList(); if (null != dataList) { int size = dataList.size(); for (int i = 0; i < size; i++) { listOperation.leftPush(key, dataList.get(i)); } } return listOperation; }
Example #18
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setList(String k, T v, long time) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); listOps.rightPush(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #19
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setList(String k, List<T> v, long time) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); listOps.rightPushAll(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setList key [{}] exception!", key, t); throw new CommonException(t); } }
Example #20
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public long getListSize(String k) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("setList key [{}]", key); try { ListOperations<String, T> listOps = redisTemplate.opsForList(); return listOps.size(key); } catch (Throwable t) { logger.error("getListSize key [{}] exception!", key, t); throw new CommonException(t); } }
Example #21
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public long getListSize(ListOperations<String, String> listOps, String k) { String key = GlobalsConstants.KEY_LIST_PREFIX + k; logger.debug("getListSize key [{}]", key); try { return listOps.size(key); } catch (Throwable t) { logger.error("getListSize key [{}] exception!", key, t); throw new CommonException(t); } }
Example #22
Source File: DataRedisContextInitializer.java From summerframework with Apache License 2.0 | 5 votes |
private void createProxyHandlers(RedisTemplate redisTemplate) { createProxyHandler(redisTemplate, ValueOperations.class, "valueOps"); createProxyHandler(redisTemplate, ListOperations.class, "listOps"); createProxyHandler(redisTemplate, SetOperations.class, "setOps"); createProxyHandler(redisTemplate, ZSetOperations.class, "zSetOps"); createProxyHandler(redisTemplate, GeoOperations.class, "geoOps"); createProxyHandler(redisTemplate, HyperLogLogOperations.class, "hllOps"); }
Example #23
Source File: RedisSupport.java From sdmq with Apache License 2.0 | 5 votes |
public boolean lrem(String key, String value) { try { ListOperations<String, String> listOperations = template.opsForList(); listOperations.remove(key, 1, value); } catch (Exception e) { return false; } return true; }
Example #24
Source File: RedisCacheService.java From DimpleBlog with Apache License 2.0 | 5 votes |
/** * 缓存List数据 * * @param key 缓存的键值 * @param dataList 待缓存的List数据 * @return 缓存的对象 */ public <T> ListOperations<String, T> setCacheList(String key, List<T> dataList) { ListOperations listOperation = redisTemplate.opsForList(); if (null != dataList) { int size = dataList.size(); for (int i = 0; i < size; i++) { listOperation.leftPush(key, dataList.get(i)); } } return listOperation; }
Example #25
Source File: RedisCacheService.java From DimpleBlog with Apache License 2.0 | 5 votes |
/** * 获得缓存的list对象 * * @param key 缓存的键值 * @return 缓存键值对应的数据 */ public <T> List<T> getCacheList(String key) { List<T> dataList = new ArrayList<>(); ListOperations<String, T> listOperation = redisTemplate.opsForList(); Long size = listOperation.size(key); for (int i = 0; i < size; i++) { dataList.add(listOperation.index(key, i)); } return dataList; }
Example #26
Source File: CacheServiceProvider.java From AsuraFramework with Apache License 2.0 | 5 votes |
@Override public void pushList(final Position position, final String key, final String... values) { final ListOperations<String, String> operation = redisTemplate.opsForList(); if (position == Position.LEFT) { operation.leftPushAll(getKey(key), values); } else { operation.rightPushAll(getKey(key), values); } }
Example #27
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 5 votes |
/** * 获取list缓存 * * @param k key * @param start start * @param end end * @return list */ @Override public List<String> getList(String k, long start, long end) { try { ListOperations<String, String> listOps = redisTemplate.opsForList(); return listOps.range(KEY_PREFIX_LIST + k, start, end); } catch (Throwable t) { LOGGER.error("获取list缓存失败key[" + KEY_PREFIX_LIST + k + ", Codeor[" + t + "]"); } return null; }
Example #28
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 5 votes |
/** * 获取总条数, 可用于分页 * * @param k key * @return long */ @Override public long getListSize(String k) { try { ListOperations<String, String> listOps = redisTemplate.opsForList(); return listOps.size(KEY_PREFIX_LIST + k); } catch (Throwable t) { LOGGER.error("获取list长度失败key[" + KEY_PREFIX_LIST + k + "], Codeor[" + t + "]"); } return 0; }
Example #29
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 5 votes |
/** * 获取总条数, 可用于分页 * * @param listOps listOps * @param k k * @return long */ @Override public long getListSize(ListOperations<String, String> listOps, String k) { try { return listOps.size(KEY_PREFIX_LIST + k); } catch (Throwable t) { LOGGER.error("获取list长度失败key[" + KEY_PREFIX_LIST + k + "], Codeor[" + t + "]"); } return 0; }
Example #30
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 5 votes |
/** * 移除list缓存 * * @param k k * @return boolean */ @Override public boolean removeOneOfList(String k) { String key = KEY_PREFIX_LIST + k; try { ListOperations<String, String> listOps = redisTemplate.opsForList(); listOps.rightPop(key); return true; } catch (Throwable t) { LOGGER.error("移除list缓存失败key[" + KEY_PREFIX_LIST + k + ", Codeor[" + t + "]"); } return false; }