Example usage for org.springframework.data.redis.core BoundHashOperations put

List of usage examples for org.springframework.data.redis.core BoundHashOperations put

Introduction

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

Prototype

void put(HK key, HV value);

Source Link

Document

Set the value of a hash key at the bound key.

Usage

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

@Override
public void updateConfig(String configInfoType, String value) {
    try {//from   w  ww.ja va  2  s  . c om
        BoundHashOperations<String, String, String> configOps = redisTemplate
                .boundHashOps(RedisUtil.getConfigQueryKey());
        configOps.put(configInfoType, value);
    } catch (Exception ex) {
        logger.error("Cannot update config info @ " + configInfoType + " with value = " + value, ex);
    }
}

From source file:net.nikey.redis.UserRepository.java

/**
 * /*from  w w  w  .  j av a  2 s  .  c  o m*/
 * @param name 
 * @param password 
 * @return
 */
public String addUser(String name, String password) {
    //long
    String uid = String.valueOf(userIdCounter.incrementAndGet());
    // save user as hash
    //KeyUtils.uid(uid) "uid:1"
    BoundHashOperations<String, String, String> userOps = template.boundHashOps(KeyUtils.uid(uid));
    userOps.put("name", name);
    userOps.put("pass", password);

    //KeyUtils.user(uid)  "user:001@163.com:uid"
    valueOps.set(KeyUtils.user(name), uid);

    //user
    users.addFirst(name);

    return addAuth(name);
}

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

@Override
public boolean getRegistrationConfig() {
    String allowRegistration;/*from ww  w .j  av  a 2  s.  c  o  m*/
    try {
        BoundHashOperations<String, String, String> configOps = redisTemplate
                .boundHashOps(RedisUtil.getConfigQueryKey());
        if (configOps.hasKey("registrationConfig")) {
            allowRegistration = (String) configOps.get("registrationConfig");
        } else {
            allowRegistration = "false";
            configOps.put("registrationConfig", "false");
        }
        return Boolean.valueOf(allowRegistration);
    } catch (Exception ex) {
        logger.error("Cannot get allow registration info ", ex);
        return false;
    }
}

From source file:com.afousan.service.RetwisRepository.java

public String addUser(String name, String password) {
    String uid = String.valueOf(userIdCounter.incrementAndGet());

    // save user as hash
    // uid -> user
    BoundHashOperations<String, String, String> userOps = template.boundHashOps(KeyUtils.uid(uid));
    userOps.put("name", name);
    userOps.put("pass", password);
    valueOps.set(KeyUtils.user(name), uid);

    users.addFirst(name);//from  w w  w. j  a  v  a 2s. co m
    return addAuth(name);
}

From source file:net.eggcanfly.spring.shiro.support.RedisSessionDao.java

protected void seriablizeSession(Session session, Serializable sessionId) {

    BoundHashOperations<String, String, Object> hashOperations = redisTemplate
            .boundHashOps(SESSION_KEY + sessionId);

    Collection<Object> attributeKeys = session.getAttributeKeys();

    for (Iterator<Object> iterator = attributeKeys.iterator(); iterator.hasNext();) {
        Object key = iterator.next();
        hashOperations.put((String) key, session.getAttribute(key));
    }// ww  w .j  a v a 2 s . c  o m

    hashOperations.put("host", session.getHost());
    hashOperations.put("lastAccessTime", session.getLastAccessTime());
    hashOperations.put("startTimestamp", session.getStartTimestamp());
    hashOperations.put("stopTimestamp", ((SimpleSession) session).getStopTimestamp());
    hashOperations.put("timeout", session.getTimeout());
}

From source file:org.shareok.data.redis.job.JobDaoImpl.java

@Override
public void updateJob(long jobId, String jobInfoType, String value) {
    try {/*from w  w w .  j a  va 2  s.co m*/
        //RedisJob job = findJobByJobId(jobId);
        BoundHashOperations<String, String, String> jobOps = redisTemplate
                .boundHashOps(RedisUtil.getJobQueryKey(jobId));
        jobOps.put(jobInfoType, value);
    } catch (Exception ex) {
        logger.error("Cannot update job info @ " + jobInfoType + " with value = " + value, ex);
    }
}

From source file:org.shareok.data.redis.job.JobDaoImpl.java

@Override
public void updateJobInfoByJobType(long jobId, String jobType, Map values) {

    try {//w  ww .j a  va2  s.c o m
        if (null == jobType || "".equals(jobType)) {
            throw new EmptyJobTypeException("Job type is empty for updating job info by job type.");
        }
        //            RedisJob job = findJobByJobId(jobId);
        switch (jobType) {
        case "ssh-upload":
        case "ssh-import": {
            if (null == values || values.get("uploadedPackagePath") == null) {
                throw new EmptyJobInfoException("Job information is empty for updating job info by job type");
            }
            BoundHashOperations<String, String, String> jobOps = redisTemplate
                    .boundHashOps(RedisUtil.getJobQueryKey(jobId));
            jobOps.put("uploadedPackagePath", (String) values.get("uploadedPackagePath"));
            if (jobType.equals("ssh-upload")) {
                jobOps.put("imported", "false");
            }
            break;
        }
        case "ssh-import-uploaded": {
            if (null == values || values.get("uploading-jobId") == null) {
                throw new EmptyJobInfoException("Job information is empty for updating job info by job type");
            }
            String uploadingJobId = (String) values.get("uploading-jobId");
            BoundHashOperations<String, String, String> jobOps = redisTemplate
                    .boundHashOps(RedisUtil.getJobQueryKey(jobId));
            jobOps.put("uploading-jobId", uploadingJobId);
            updateJob(Long.parseLong(uploadingJobId), "imported", "true");
            break;
        }
        }

    } catch (EmptyJobTypeException | EmptyJobInfoException ex) {
        logger.error("Cannot update job info for the job type " + jobType, ex);
    }

}

From source file:org.shareok.data.redis.server.RepoServerDaoImpl.java

@Override
public RepoServer updateServer(int serverId, String infoType, String value) {
    RepoServer server = null;/* w ww  .j  a va2s .  c  o  m*/
    try {
        if (infoType.equals("serverName")) {
            RepoServer existingServer = findServerById(serverId);
            if (null == existingServer) {
                throw new NonExistingServerException("The server to be updated does not exist!");
            }
            String oldServerName = existingServer.getServerName();
            if (!oldServerName.equals(value)) {
                redisTemplate.boundHashOps(ShareokdataManager.getRedisServerNameIdMatchingTable())
                        .delete(ShareokdataManager.getRedisServerNameIdMatchingTable(), oldServerName);
                redisTemplate.boundHashOps(ShareokdataManager.getRedisServerNameIdMatchingTable()).put(value,
                        String.valueOf(serverId));
            }
        }
        server = findServerById(serverId);
        BoundHashOperations<String, String, String> serverOps = redisTemplate
                .boundHashOps(RedisUtil.getServerQueryKey(serverId));
        serverOps.put(infoType, value);
    } catch (Exception ex) {
        logger.error("Cannot update server info @ " + infoType + " with value = " + value, ex);
    }
    return server;
}

From source file:org.shareok.data.redis.server.RepoServerDaoImpl.java

public void updateRepoTypeServerFieldInfo(Map<String, String> repoTypeServerFieldInfo, RepoServer server) {
    BoundHashOperations<String, String, String> serverOps = redisTemplate
            .boundHashOps(RedisUtil.getServerQueryKey(server.getServerId()));
    if (null != serverOps) {
        for (String key : repoTypeServerFieldInfo.keySet()) {
            serverOps.put(key, repoTypeServerFieldInfo.get(key));
        }/*from w ww .j a  va  2s . c  o m*/
    }
}