| | |
| | | * @param hashKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object hashGet(String hashKey,String key) { |
| | | public Object hashGet(String hashKey,Object key) { |
| | | try { |
| | | return redisTemplate.opsForHash().get(hashKey,key); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 新增-左插入 |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object leftPush(String listKey,Object value) { |
| | | try { |
| | | return redisTemplate.opsForList().leftPush(listKey,value); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 新增-左插入(存在才插入) |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object leftPushIfPresent(String listKey,Object value) { |
| | | try { |
| | | return redisTemplate.opsForList().leftPushIfPresent(listKey,value); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 新增-右插入(存在才插入) |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object rightPushIfPresent(String listKey,Object value) { |
| | | try { |
| | | return redisTemplate.opsForList().rightPushIfPresent(listKey,value); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 新增-右插入 |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object rightPush(String listKey,Object value) { |
| | | try { |
| | | return redisTemplate.opsForList().rightPush(listKey,value); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 弹出-左 |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object leftPop(String listKey) { |
| | | try { |
| | | return redisTemplate.opsForList().leftPop(listKey); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 弹出-右 |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object rightPop(String listKey) { |
| | | try { |
| | | return redisTemplate.opsForList().rightPop(listKey); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 获取 |
| | | * |
| | | * @param key 键 |
| | | * @param index 索引 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object listGet(String key, long index) { |
| | | try { |
| | | return redisTemplate.opsForList().index(key,index); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 获取长度 |
| | | * |
| | | * @param listKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object listSize(String listKey) { |
| | | try { |
| | | return redisTemplate.opsForList().size(listKey); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * list 删除 |
| | | * |
| | | * @param listKey 键 |
| | | * @param index index=0, 删除所有值等于value的元素; index>0, 从头部开始删除第一个值等于value的元素; index<0, 从尾部开始删除第一个值等于value的元素 |
| | | * @param value 删除的值 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object listRemove(String listKey,long index,Object value) { |
| | | try { |
| | | return redisTemplate.opsForList().remove(listKey, index, value); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | } |