1.hashSet(String key, Object hashKey, Object value)
public boolean hashSet(String key, Object hashKey, Object value) {
try {
redisTemplate.opsForHash().put(key, hashKey, value);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
2. hashSetIfAbsent(String key, Object hashKey, Object value)
public boolean hashSetIfAbsent(String key, Object hashKey, Object value) {
return redisTemplate.opsForHash().putIfAbsent(key, hashKey, value);
}
3.hashGet(String key, Object hashKey)
public Object hashGet(String key, Object hashKey) {
return key == null ? null : redisTemplate.opsForHash().get(key, hashKey);
}
4. hashKeys(String key)
public Set hashKeys(String key) {
return redisTemplate.opsForHash().keys(key);
}
5. hashGetAll(String key)
public Map
6.hashExists(String key, String hashKey)
public boolean hashExists(String key, String hashKey) {
return redisTemplate.opsForHash().hasKey(key, hashKey);
}
7.hashDelete(String key, Object… hashKey)
public Long hashDelete(String key, Object... hashKey) {
return redisTemplate.opsForHash().delete(key, hashKey);
}
8.hashIncr(String key, Object hashKey, long delta)
public long hashIncr(String key, Object hashKey, long delta) {
if (delta < 0) {
throw new RuntimeException("递增因子必须大于0");
}
return redisTemplate.opsForHash().increment(key, hashKey, delta);
}
9.hashDecr(String key, Object hashKey, long delta)
public long hashDecr(String key, Object hashKey, long delta) {
if (delta < 0) {
throw new RuntimeException("递减因子必须大于0");
}
return redisTemplate.opsForHash().increment(key, hashKey, -delta);
}



