public boolean hsetnx(String key, Object field, String value) { hashOps = redisTemplate.opsForHash(); return hashOps.putIfAbsent(key, field, value); }
public void hincreby(String key, Object field, Integer delta) { hashOps = redisTemplate.opsForHash(); hashOps.increment(key, field, delta); }
public boolean hexists(String key, Object field) { hashOps = redisTemplate.opsForHash(); return hashOps.hasKey(key, field); }
/** * Hash数据类型 读取 key绑定的hash集合 * * @param key * @return map集合 key-value */ public Map<Object, Object> getHash(String key) { hashOps = redisTemplate.opsForHash(); return hashOps.entries(key); }
/** * Hash数据类型 读取 key绑定的hash集合的keys * * @param key * @return set集合 */ public Set getHashKeys(String key) { hashOps = redisTemplate.opsForHash(); return (Set) hashOps.keys(key); }
/** * Hash数据类型 查找 key绑定的hash集合的大小 * * @param key * @return */ public long getHashSize(String key) { hashOps = redisTemplate.opsForHash(); return hashOps.size(key); }
/** * Hash数据类型 查找 key绑定的hash集合中hashKey的值 * * @param key * @param hashKey * @return */ public Object getHashValue(String key, Object hashKey) { hashOps = redisTemplate.opsForHash(); return hashOps.get(key, hashKey); }
/** * 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); }
/** * Hash数据类型 批量 key绑定的hash集合新增元素 * * @param key * @param map */ public void putHash(String key, Map<Object, Object> map) { hashOps = redisTemplate.opsForHash(); hashOps.putAll(key, map); }
/** * 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); }