List of usage examples for org.springframework.data.redis.core HashOperations put
void put(H key, HK hashKey, HV value);
From source file:com.easarrive.datasource.redis.etago.AbstractDaoByRedisTemplate.java
public void hashPut(K key, F feild, V bean) { HashOperations<K, F, V> hashOperations = redisTemplate.opsForHash(); hashOperations.put(key, feild, bean); }
From source file:org.shareok.data.redis.UserDaoImpl.java
@Override public RedisUser updateUser(final RedisUser user) { try {/*w ww. j ava 2s. co m*/ long uid = user.getUserId(); redisTemplate.setConnectionFactory(connectionFactory); final String userKey = RedisUtil.getUserQueryKey(uid); List<Object> pipelinedResults = redisTemplate.executePipelined(new RedisCallback() { public Object doInRedis(RedisConnection connection) throws DataAccessException { String uid = String.valueOf(user.getUserId()); Map userInfo = redisTemplate.opsForHash().entries(userKey); String oldUserEmail = (String) userInfo.get("email"); HashOperations operations = redisTemplate.opsForHash(); operations.put(userKey, "userName", (null != user.getUserName() ? user.getUserName() : user.getEmail())); operations.put(userKey, "email", user.getEmail()); operations.put(userKey, "password", user.getPassword()); operations.put(userKey, "isActive", String.valueOf(true)); operations.put(userKey, "sessionKey", (null != user.getSessionKey() ? user.getSessionKey() : "")); if (!oldUserEmail.equals(user.getEmail())) { operations.delete("users", oldUserEmail); operations.put("users", user.getEmail(), uid); } return null; } }); } catch (Exception ex) { logger.error("Cannot update a user", ex); } return user; }
From source file:com.company.project.service.dao.RedisDao.java
/** * //from w w w . j av a 2 s .c o m * @param objectKey ex. "USER", "GEM", "GROUP" * @param key ex. "id of user", "id of gem", "id of group" * @param object */ public void setHash(String objectKey, String key, String object) { HashOperations opsForHash = redisTemplate.opsForHash(); opsForHash.put(objectKey, key, object); }