/** * Append to an existing value in the cache. * * @param cas cas identifier (ignored in the ascii protocol) * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<Boolean> append(long cas, String key, Object val) { return append(cas, key, val, transcoder); }
/** * Append to an existing value in the cache. * * <p> * Note that the return will be false any time a mutation has not occurred. * </p> * * @param cas cas identifier (ignored in the ascii protocol) * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change to the * value * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ public OperationFuture<Boolean> append(long cas, String key, Object val) { return append(cas, key, val, transcoder); }
/** * Append to an existing value in the cache. * * <p> * Note that the return will be false any time a mutation has not occurred. * </p> * * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change to the * value * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<Boolean> append(String key, Object val) { return append(0, key, val, transcoder); }
/** * Append to an existing value in the cache. * * <p> * Note that the return will be false any time a mutation has not occurred. * </p> * * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change to the * value * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<Boolean> append(String key, Object val) { return append(0, key, val, transcoder); }
/** * Append to an existing value in the cache. * * <p>Note that the return will be false any time a mutation has not * occurred.</p> * * @param cas cas identifier (ignored in the ascii protocol) * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change * to the value * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<Boolean> append(long cas, String key, Object val) { return append(cas, key, val, transcoder); }
/** * Append to an existing value in the cache. * * <p>Note that the return will be false any time a mutation has not * occurred.</p> * * @param cas cas identifier (ignored in the ascii protocol) * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change * to the value * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<Boolean> append(long cas, String key, Object val) { return append(cas, key, val, transcoder); }
/** * Append to an existing value in the cache. * * If 0 is passed in as the CAS identifier, it will override the value * on the server without performing the CAS check. * * <p> * Note that the return will be false any time a mutation has not occurred. * </p> * * @param cas cas identifier (ignored in the ascii protocol) * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change to the * value * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<Boolean> append(long cas, String key, Object val) { return append(cas, key, val, transcoder); }
/** * Append to an existing value in the cache. * * If 0 is passed in as the CAS identifier, it will override the value * on the server without performing the CAS check. * * <p> * Note that the return will be false any time a mutation has not occurred. * </p> * * @param cas cas identifier (ignored in the ascii protocol) * @param key the key to whose value will be appended * @param val the value to append * @return a future indicating success, false if there was no change to the * value * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<Boolean> append(long cas, String key, Object val) { return append(cas, key, val, transcoder); }
public void testAppend() throws Exception { MemcachedClient client = bootstrapClient(); Future<Boolean> b = client.append(0, "key", "WithAddition"); assertTrue(b.get()); assertEquals("myStringValueWithAddition", client.get("key")); b = client.append(0, "appendkey", "val"); assertFalse(b.get()); assertNull(client.get("appendkey")); }
/** * Update context key list. * * @param suffix the suffix * @param namespace the namespace * @param key the storage key * @return whether the update was a success * @throws IOException if an error occurs */ private boolean updateContextKeyList(final String suffix, final String namespace, final String key) throws IOException { final String listKey = namespace + suffix; final String newItem = key + CTX_KEY_LIST_DELIMITER; final boolean success = handleAsyncResult(memcacheClient.append(listKey, newItem, stringTranscoder)); if (!success) { // Assume list does not exist and create it return handleAsyncResult(memcacheClient.add(listKey, 0, newItem, stringTranscoder)); } return success; } }
future = client.append(0L, key, value); break; case prepend: