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

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

Introduction

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

Prototype

@Nullable
Boolean hasKey(Object key);

Source Link

Document

Determine if given hash key exists at the bound key.

Usage

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

@Override
public boolean getRegistrationConfig() {
    String allowRegistration;/*from w w  w. ja v a  2  s  .  co 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:org.shareok.data.redis.RedisConfigImpl.java

@Override
public String getFileDownloadPathByNameKey(String nameKey) {
    String path = null;/*from   w  w w  .  jav a  2 s  . c  om*/
    try {
        BoundHashOperations<String, String, String> fileDownloadPathsOps = redisTemplate
                .boundHashOps("file_download_paths");
        if (fileDownloadPathsOps.hasKey(nameKey)) {
            return (String) fileDownloadPathsOps.get(nameKey);
        } else {
            throw new FileDownloadPathNotExistException(
                    "The key " + nameKey + " for file downloading does not exist!");
        }
    } catch (Exception ex) {
        logger.error("Cannot find the download path ", ex);
    }
    return path;
}