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

The following examples show how to use redis.clients.jedis.Jedis#append() . 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: JedisSingleDemo.java    From Redis-4.x-Cookbook with MIT License 8 votes vote down vote up
public static void main(String[] args) {
    //Connecting to localhost Redis server
    Jedis jedis = new Jedis("localhost");

    //String operations
    String restaurant = "Extreme Pizza";
    jedis.set(restaurant, "300 Broadway, New York, NY");
    jedis.append(restaurant, " 10011");
    String address = jedis.get("Extreme Pizza");
    System.out.printf("Address for %s is %s\n", restaurant, address);

    //List operations
    String listKey = "favorite_restaurants";
    jedis.lpush(listKey, "PF Chang's", "Olive Garden");
    jedis.rpush(listKey, "Outback Steakhouse", "Red Lobster");
    List<String> favoriteRestaurants = jedis.lrange(listKey, 0, -1);
    System.out.printf("Favorite Restaurants: %s\n", favoriteRestaurants);

    System.exit(0);
}
 
Example 2
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * 通过key向指定的value值追加值
 * </p>
 *
 * @param key
 * @param str
 * @return 成功返回 添加后value的长度 失败 返回 添加的 value 的长度 异常返回0L
 */
public Long append(String key, String str) {
    Jedis jedis = null;
    Long res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.append(key, str);
    } catch (Exception e) {

        log.error(e.getMessage());
        return 0L;
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 3
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 6 votes vote down vote up
@Override
public Long append(String key, String str) {
    Jedis jedis = null;
    Long res = null;
    try {
        jedis = pool.getResource();
        res = jedis.append(key, str);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
        return 0L;
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 4
Source File: LogDB.java    From VileBot with MIT License 6 votes vote down vote up
public static void addItem( String chatMessage )
{
    Jedis jedis = pool.getResource();
    try
    {
        if ( jedis.strlen( logKey ) > MAX_LOG_SIZE )
        {
            jedis.set( logKey, StringUtils.right( jedis.get( logKey ), MAX_LOG_SIZE - chatMessage.length() ) );
        }
        jedis.append( logKey, chatMessage );
    }
    finally
    {
        pool.returnResource( jedis );
    }
}
 
Example 5
Source File: UrlUtil.java    From BigData with GNU General Public License v3.0 5 votes vote down vote up
public static void juageUrl(String userHref) {
	// 用户url去重
	String md5 = MD5Filter.md5(userHref);
	Jedis jedis = JedisUtil.getJedis();
	if (jedis.get(md5) == null) {
		jedis.append(md5, "md5url");
		jedis.lpush(JedisUtil.urlkey, userHref);
		JedisUtil.returnResource(jedis);
	} else {
		JedisUtil.returnResource(jedis);
	}
}
 
Example 6
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long append0(Jedis j, String key, String value) {
	return j.append(key, value);
}
 
Example 7
Source File: JedisUtil.java    From Project with Apache License 2.0 3 votes vote down vote up
/**
 * 在指定的key中追加value
 * 
 * @param key
 * @param  value
 * @return long 追加后value的长度
 **/
public long append(String key, String value) {
	Jedis jedis = getJedis();
	long len = jedis.append(key, value);
	jedis.close();
	return len;
}
 
Example 8
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 在指定的key中追加value
 * 
 * @param String
 *            key
 * @param String
 *            value
 * @return long 追加后value的长度
 * **/
public long append(String key, String value) {
	Jedis jedis = getJedis();
	long len = jedis.append(key, value);
	returnJedis(jedis);
	return len;
}