Example usage for org.springframework.data.redis.core HashOperations delete

List of usage examples for org.springframework.data.redis.core HashOperations delete

Introduction

In this page you can find the example usage for org.springframework.data.redis.core HashOperations delete.

Prototype

Long delete(H key, Object... hashKeys);

Source Link

Document

Delete given hash hashKeys .

Usage

From source file:com.easarrive.datasource.redis.etago.AbstractDaoByRedisTemplate.java

public Long hashDelete(K key, F... feilds) {
    HashOperations<K, F, V> hashOperations = redisTemplate.opsForHash();
    Long count = hashOperations.delete(key, feilds);
    return count;
}

From source file:com.company.project.service.dao.RedisDao.java

public void deleteHash(Object objectKey, Object... key) {
    HashOperations opsForHash = redisTemplate.opsForHash();
    opsForHash.delete(objectKey, key);
}

From source file:org.shareok.data.redis.UserDaoImpl.java

@Override
public RedisUser updateUser(final RedisUser user) {
    try {/*w  ww  .  j  a  va2  s.c  om*/
        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;
}