Java Code Examples for redis.clients.jedis.Jedis#mset()

The following examples show how to use redis.clients.jedis.Jedis#mset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JedisUtil.java    From newblog with Apache License 2.0 7 votes vote down vote up
public void mset(Map<String, String> map) {
        Jedis jedis = null;
        try {
            jedis = getJedis();
            if (jedis != null) {
                if (map != null) {
                    int len = map.size();
                    if (len > 0) {
                        String[] keys = map.keySet().toArray(new String[0]);
                        String[] strings = new String[len * 2];

                        for (int i = 0; i < len; i++) {
                            strings[2 * i] = keys[i];
                            strings[2 * i + 1] = map.get(keys[i]);
                        }
//						logger.info(Arrays.toString(strings));
                        jedis.mset(strings);
                    }
                }
            } else {
                logger.error("mset opt connection null error!");
            }
        } catch (JedisConnectionException e) {
            if (jedis != null) {
                jedis.close();
                jedis = null;
            }
            logger.error("mset connect error:", e);
        } finally {
            returnJedisResource(jedis);
        }
    }
 
Example 2
Source File: JedisUtil.java    From Project with Apache License 2.0 5 votes vote down vote up
/**
 * 批量存储记录
 * 
 * @param  keysvalues 例:keysvalues="key1","value1","key2","value2";
 * @return String 状态码
 */
public String mset(String... keysvalues) {
	Jedis jedis = getJedis();
	String str = jedis.mset(keysvalues);
	jedis.close();
	return str;
}
 
Example 3
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public String mset(String... keysvalues) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = pool.getResource();
        res = jedis.mset(keysvalues);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 4
Source File: RedisMset.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Override
public String execute(Jedis jedis) {
    return jedis.mset(kvs);
}
 
Example 5
Source File: RedisMset.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Override
public String execute(Jedis jedis) {
    return jedis.mset(kvs);
}
 
Example 6
Source File: RedisStore.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public void putAll(Map<String, String> entries) {
  Jedis jedis = pool.getResource();
  jedis.mset(kvToList(entries));
  jedis.close();
}
 
Example 7
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private String mset0(Jedis j, String... keysvalues) {
	return j.mset(keysvalues);
}
 
Example 8
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * 批量的设置key:value,可以一个
 * </p>
 * <p>
 * example:
 * </p>
 * <p>
 * obj.mset(new String[]{"key2","value1","key2","value2"})
 * </p>
 *
 * @param keysvalues
 * @return 成功返回OK 失败 异常 返回 null
 *
 */
public String mset(String... keysvalues) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.mset(keysvalues);
    } catch (Exception e) {

        log.error(e.getMessage());
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 9
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 批量存储记录
 * 
 * @param String
 *            keysvalues 例:keysvalues="key1","value1","key2","value2";
 * @return String 状态码
 * */
public String mset(String... keysvalues) {
	Jedis jedis = getJedis();
	String str = jedis.mset(keysvalues);
	returnJedis(jedis);
	return str;
}