/*
(non-Javadoc)

@see net.rubyeye.xmemcached.MemcachedClient#append(java.lang.String, java.lang.Object, long)
492230
public final boolean append(String key, final Object value, final long timeout)
      throws TimeoutException, InterruptedException, MemcachedException {
    key = this.preProcessKey(key);
    byte[] keyBytes = this.checkStoreArguments(key, 0, value);
    return this.sendStoreCommand(
        this.commandFactory.createAppendCommand(key, keyBytes, value, false, this.transcoder),
        timeout);
  }
783246
public void appendEnd(final StringBuffer buffer, final Object object) {
        if (!this.fieldSeparatorAtEnd) {
            removeLastFieldSeparator(buffer);
        }
        appendContentEnd(buffer);
        unregister(object);
    }
678626
OutputStream append(String src, int buffersize, Progressable progress
      ) throws IOException {
    checkOpen();
    clearFileStatusCache();

    FileStatus stat = null;
    LocatedBlock lastBlock = null;
    boolean success = false;
    
    try {
      stat = getFileInfo(src);
      if (namenodeProtocolProxy != null
            && namenodeProtocolProxy.isMethodSupported(
                "appendAndFetchOldGS", String.class, String.class)) {
        LocatedBlockWithOldGS loc = namenode.appendAndFetchOldGS(src, 
            clientName);
        lastBlock = loc;
        if (loc != null) {
          updateNamespaceIdIfNeeded(loc.getNamespaceID());
          updateDataTransferProtocolVersionIfNeeded(loc.getDataProtocolVersion());
          getNewNameNodeIfNeeded(loc.getMethodFingerPrint());
        }
      } else if (namenodeProtocolProxy != null 
               && dataTransferVersion >= DataTransferProtocol.APPEND_BLOCK_VERSION) {
        // fail the request if the data transfer version support the new append 
        // protocol, but the namenode method is not supported.
        // This should not happen unless there is a bug.
        throw new IOException ("DataTransferVersion " + dataTransferVersion +
              "requires the method appendAndFetchOldGS is supported in Namenode");
      } else if (namenodeProtocolProxy != null
          && namenodeProtocolProxy.isMethodSupported(
              "appendAndFetchMetaInfo", String.class, String.class)) {
        LocatedBlockWithMetaInfo loc = namenode.appendAndFetchMetaInfo(src,
            clientName);
        lastBlock = loc;
        if (loc != null) {
          updateNamespaceIdIfNeeded(loc.getNamespaceID());
          updateDataTransferProtocolVersionIfNeeded(loc.getDataProtocolVersion());
          getNewNameNodeIfNeeded(loc.getMethodFingerPrint());
        }
      } else {
        lastBlock = namenode.append(src, clientName);
      }

      OutputStream result = new DFSOutputStream(this, src, buffersize, progress,
          lastBlock, stat, conf.getInt("io.bytes.per.checksum", 512), namespaceId);
      leasechecker.put(src, result);
      success = true;

      return result;
    } catch(RemoteException re) {
      throw re.unwrapRemoteException(FileNotFoundException.class,
                                     AccessControlException.class,
                                     NSQuotaExceededException.class,
                                     DSQuotaExceededException.class);
    } finally {
      if (!success) {
        try {
          namenode.abandonFile(src, clientName);
        } catch (RemoteException e) {
          if (e.unwrapRemoteException() instanceof LeaseExpiredException) {
            LOG.debug(String.format(
              "client %s attempting to abandon file %s which it does not own",
              clientName, src), 
              e
            );
          } else {
            throw e;
          }
        }
      }
    }
  }
397450
public void append(String s) {
        int length = s.length();
        if (this.length + length > this.ch.length) {
            int newLength = this.ch.length*2;
            if (newLength < this.length + length + DEFAULT_SIZE)
                newLength = this.ch.length + length + DEFAULT_SIZE;
            char[] newch = new char[newLength];            
            System.arraycopy(this.ch, 0, newch, 0, this.length);
            this.ch = newch;
        }
        s.getChars(0, length, this.ch, this.length);
        this.length += length;
    }
787174
public final <T> boolean add(String key, final int exp, final T value,
      final Transcoder<T> transcoder, final long timeout)
      throws TimeoutException, InterruptedException, MemcachedException {
    key = this.preProcessKey(key);
    return this.add0(key, exp, value, transcoder, timeout);
  }
1206340
static void append(Appendable outputBuf, CharSequence cs) {
    try {
      outputBuf.append(cs);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
223711
public static Single<Long> addAll(CacheConfigBean cacheConfigBean, String key, Set members) {
        return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheSetAdd", new JSONObject() {{
            put("cacheConfig", cacheConfigBean);
            put("key", key);
            put("members", members);
        }}).map(unitResponseObject -> {
            unitResponseObject.throwExceptionIfNotSuccess();
            if (unitResponseObject.getData() == null)
                return 0L;
            return unitResponseObject.dataToLong();
        });
    }
334922
@Override
    public void append(Append append) {
        log.trace("Processing append received from client {}", append);
        UUID id = append.getWriterId();
        synchronized (lock) {
            Long lastEventNumber = latestEventNumbers.get(Pair.of(append.getSegment(), id));
            Preconditions.checkState(lastEventNumber != null, "Data from unexpected connection: %s.", id);
            Preconditions.checkState(append.getEventNumber() >= lastEventNumber, "Event was already appended.");
            waitingAppends.put(id, append);
        }
        pauseOrResumeReading();
        performNextWrite();
    }
795260
@Override
    public CompletableFuture<Void> append(String streamSegmentName, byte[] data, Collection<AttributeUpdate> attributeUpdates, Duration timeout) {
        return invoke(
                streamSegmentName,
                container -> container.append(streamSegmentName, data, attributeUpdates, timeout),
                "append", streamSegmentName, data.length, attributeUpdates);
    }
1024857
protected void appendCopy(RoaringArray sa, int startingIndex, int end) {
    extendArray(end - startingIndex);
    for (int i = startingIndex; i < end; ++i) {
      this.keys[this.size] = sa.keys[i];
      this.values[this.size] = sa.values[i].clone();
      this.size++;
    }
  }
716113
function MemcachedBackend(options) {
  this.type = 'memcached';
  const client = (this.client = createClient(options));
  this._clientGet = promisify(client.get, { context: client });
  this._clientSet = promisify(client.set, { context: client });
  this._clientDel = promisify(client.del, { context: client });
}
969466
protected static final void append(StringBuilder builder, String key, String value) {

		// Convert key
		String formattedKey = key.replace('[', '.').replace("]", "");

		// Append key
		char c;
		boolean replace = false;
		char[] chars = formattedKey.toCharArray();
		for (int i = 0; i < chars.length; i++) {
			c = chars[i];
			if ((c > 0xFF) || KEY_ESCAPES[c] != 0) {
				replace = true;
				break;
			}
		}
		if (replace) {
			appendWithEscapes(builder, formattedKey, KEY_ESCAPES);
		} else {
			builder.append(formattedKey);
		}
		builder.append('=');

		// Append value
		if (value != null && !value.isEmpty()) {
			replace = false;
			chars = value.toCharArray();
			for (int i = 0; i < chars.length; i++) {
				c = chars[i];
				if ((c > 0xFF) || VALUE_ESCAPES[c] != 0) {
					replace = true;
					break;
				}
			}
			if (replace) {
				appendWithEscapes(builder, value, VALUE_ESCAPES);
			} else {
				builder.append(value);
			}
		}

		// Line break
		builder.append(LINE_SEPARATOR);
	}
232035
protected void append(RoaringArray sa, int startingIndex, int end) {
    extendArray(end - startingIndex);
    for (int i = startingIndex; i < end; ++i) {
      this.keys[this.size] = sa.keys[i];
      this.values[this.size] = sa.values[i];
      this.size++;
    }
  }
1040007
private long beforeAppend(DecoratedKey decoratedKey)
    {
        assert decoratedKey != null : "Keys must not be null"; // empty keys ARE allowed b/c of indexed column values
        if (lastWrittenKey != null && lastWrittenKey.compareTo(decoratedKey) >= 0)
            throw new RuntimeException("Last written key " + lastWrittenKey + " >= current key " + decoratedKey + " writing into " + getFilename());
        return (lastWrittenKey == null) ? 0 : dataFile.getFilePointer();
    }
914276
public void append(final StringBuffer sb) {
        if (sb == null) {
            return;
        }
        provideCapacity(length + sb.length());
        sb.getChars(0, sb.length(), c, length);
        length += sb.length();
    }
45853
public long addAndGet(long delta)
      throws MemcachedException, InterruptedException, TimeoutException {
    if (delta >= 0) {
      return this.memcachedClient.incr(this.key, delta, this.initialValue);
    } else {
      return this.memcachedClient.decr(this.key, -delta, this.initialValue);
    }
  }
697048
public long get() throws MemcachedException, InterruptedException, TimeoutException {
    Object result = this.memcachedClient.get(this.key);
    if (result == null) {
      throw new MemcachedClientException("key is not existed.");
    } else {
      if (result instanceof Long)
        return (Long) result;
      else
        return Long.valueOf(((String) result).trim());
    }
  }