public static void deleteItem(String threadId, String replyDateTime) { Table table = dynamoDB.getTable(tableName); table.deleteItem("Id", threadId, "ReplyDateTime", replyDateTime); }
@Override public void delete(String functionName, String uniqueID) { Table table = dynamoDB.getTable(tableName); table.deleteItem("JobKey", jobIdKey(functionName, uniqueID)); }
@Override public boolean delete(final Object key) { // The CacheWriter should remove from the external storage the entry identified by the specified key. // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.DYNAMODB_LOG.trace("[DS0112] DynamoDB store: Deleting {} cache entry with key {}", getCacheName(), key); final boolean deleted; Timer.Context timerCtx = timers.deleteTimer.time(); try { deleted = table.deleteItem(requestFactory.resolveDeleteItemSpec(key)).getItem() != null; } catch (Exception e) { Loggers.DYNAMODB_LOG.error("[DS0113] {}, {}", e.getMessage(), e); throw new PersistenceException(e.getMessage(), e); } finally { timerCtx.stop(); } if (deleted) { Loggers.DYNAMODB_LOG.trace("[DS0113] DynamoDB store: Deleted item with key {}", key); } return deleted; }
@Override public String remove(String key) { Assert.hasText(key, "'key' must not be empty."); awaitForActive(); Item item = this.table.deleteItem( new DeleteItemSpec() .withPrimaryKey(KEY, key) .withReturnValues(ReturnValue.ALL_OLD)) .getItem(); return getValueIfAny(item); }
@Override public String remove(String key) { Assert.hasText(key, "'key' must not be empty."); awaitForActive(); Item item = this.table.deleteItem( new DeleteItemSpec() .withPrimaryKey(KEY, key) .withReturnValues(ReturnValue.ALL_OLD)) .getItem(); return getValueIfAny(item); }
final boolean deleted = table.deleteItem(requestFactory.resolveDeleteItemSpec(key)).getItem() != null;
public static void main(String[] args) { AmazonDynamoDBClient client = new AmazonDynamoDBClient(); client.setEndpoint("http://localhost:8000"); DynamoDB dynamoDB = new DynamoDB(client); Table table = dynamoDB.getTable("Movies"); // Conditional delete (will fail) DeleteItemSpec deleteItemSpec = new DeleteItemSpec() .withPrimaryKey(new PrimaryKey("year", 2015, "title", "The Big New Movie")) .withConditionExpression("info.rating <= :val") .withValueMap(new ValueMap() .withNumber(":val", 5.0)); System.out.println("Attempting a conditional delete..."); try { table.deleteItem(deleteItemSpec); System.out.println("DeleteItem succeeded"); } catch (Exception e) { e.printStackTrace(); System.out.println("DeleteItem failed"); } }
private static void deleteItem() { Table table = dynamoDB.getTable(tableName); try { DeleteItemSpec deleteItemSpec = new DeleteItemSpec() .withPrimaryKey("Id", 120) .withConditionExpression("#ip = :val") .withNameMap(new NameMap() .with("#ip", "InPublication")) .withValueMap(new ValueMap() .withBoolean(":val", false)) .withReturnValues(ReturnValue.ALL_OLD); DeleteItemOutcome outcome = table.deleteItem(deleteItemSpec); // Check the response. System.out.println("Printing item that was deleted..."); System.out.println(outcome.getItem().toJSONPretty()); } catch (Exception e) { System.err.println("Error deleting item in " + tableName); System.err.println(e.getMessage()); } } }
path.toString(), idempotent, () -> table.deleteItem(key));
final boolean deleted = table.deleteItem(requestFactory.resolveDeleteItemSpec(en.getKey())).getItem() != null;