public void set(String key, String value, int ttl, Boolean prevExist) throws EtcdClientException {
        Preconditions.checkNotNull(key);
        Preconditions.checkNotNull(value);

        List<BasicNameValuePair> list = Lists.newArrayList();
        list.add(new BasicNameValuePair("value", value));
        if (ttl > 0) {
            list.add(new BasicNameValuePair("ttl", String.valueOf(ttl)));
        }
        if (prevExist != null) {
            list.add(new BasicNameValuePair("prevExist", String.valueOf(prevExist)));
        }

        put(key, list, null, new int[]{200, 201});
    }
public void set ( String key , String value , int ttl , Boolean prevExist ) throws EtcdClientException { Preconditions . checkNotNull ( key ) ; Preconditions . checkNotNull ( value ) ; List < BasicNameValuePair > list = Lists . newArrayList ( ) ; list . add ( new BasicNameValuePair ( "value" , value ) ) ; if ( ttl > 0 ) { list . add ( new BasicNameValuePair ( "ttl" , String . valueOf ( ttl ) ) ) ; } if ( prevExist != null ) { list . add ( new BasicNameValuePair ( "prevExist" , String . valueOf ( prevExist ) ) ) ; } put ( key , list , null , new int [ ] { 200 , 201 } ) ; }
Setting the value of a key with ttl and optional prevExist(update key ttl)
@param key the key
@param value the value
@param ttl the ttl
@param prevExist exists before