Exemplo n.º 1
0
 public boolean hsetnx(String key, Object field, String value) {
   hashOps = redisTemplate.opsForHash();
   return hashOps.putIfAbsent(key, field, value);
 }
Exemplo n.º 2
0
 public void hincreby(String key, Object field, Integer delta) {
   hashOps = redisTemplate.opsForHash();
   hashOps.increment(key, field, delta);
 }
Exemplo n.º 3
0
 public boolean hexists(String key, Object field) {
   hashOps = redisTemplate.opsForHash();
   return hashOps.hasKey(key, field);
 }
Exemplo n.º 4
0
 /**
  * Hash数据类型 读取 key绑定的hash集合
  *
  * @param key
  * @return map集合 key-value
  */
 public Map<Object, Object> getHash(String key) {
   hashOps = redisTemplate.opsForHash();
   return hashOps.entries(key);
 }
Exemplo n.º 5
0
 /**
  * Hash数据类型 读取 key绑定的hash集合的keys
  *
  * @param key
  * @return set集合
  */
 public Set getHashKeys(String key) {
   hashOps = redisTemplate.opsForHash();
   return (Set) hashOps.keys(key);
 }
Exemplo n.º 6
0
 /**
  * Hash数据类型 查找 key绑定的hash集合的大小
  *
  * @param key
  * @return
  */
 public long getHashSize(String key) {
   hashOps = redisTemplate.opsForHash();
   return hashOps.size(key);
 }
Exemplo n.º 7
0
 /**
  * Hash数据类型 查找 key绑定的hash集合中hashKey的值
  *
  * @param key
  * @param hashKey
  * @return
  */
 public Object getHashValue(String key, Object hashKey) {
   hashOps = redisTemplate.opsForHash();
   return hashOps.get(key, hashKey);
 }
Exemplo n.º 8
0
 /**
  * Hash数据类型 查找 key绑定的hash集合中hashKey 的元素是否存在
  *
  * @param key
  * @param hashKey
  * @return true存在 false不存在
  */
 public boolean hasHashKey(String key, Object hashKey) {
   hashOps = redisTemplate.opsForHash();
   return hashOps.hasKey(key, hashKey);
 }
Exemplo n.º 9
0
 /**
  * Hash数据类型 批量 key绑定的hash集合新增元素
  *
  * @param key
  * @param map
  */
 public void putHash(String key, Map<Object, Object> map) {
   hashOps = redisTemplate.opsForHash();
   hashOps.putAll(key, map);
 }
Exemplo n.º 10
0
 /**
  * Hash数据类型 key绑定的hash集合新增元素
  *
  * @param key
  * @param hashKey
  * @param hashValue
  */
 public void putHash(String key, Object hashKey, Object hashValue) {
   hashOps = redisTemplate.opsForHash();
   hashOps.put(key, hashKey, hashValue);
 }