@Override public void put(String key, String value) { Assert.hasText(key, "'key' must not be empty."); Assert.hasText(value, "'value' must not be empty."); awaitForActive(); Item item = new Item() .withPrimaryKey(KEY, key) .withString(VALUE, value); if (this.timeToLive != null && this.timeToLive > 0) { item = item.withLong(TTL, (System.currentTimeMillis() + this.timeToLive) / 1000); } this.table.putItem(item); }
@Override public void put(String key, String value) { Assert.hasText(key, "'key' must not be empty."); Assert.hasText(value, "'value' must not be empty."); awaitForActive(); Item item = new Item() .withPrimaryKey(KEY, key) .withString(VALUE, value); if (this.timeToLive != null && this.timeToLive > 0) { item = item.withLong(TTL, (System.currentTimeMillis() + this.timeToLive) / 1000); } this.table.putItem(item); }
/** * Converts a {@link DDBPathMetadata} to a DynamoDB item. * * Can ignore {@code IS_AUTHORITATIVE} flag if {@code ignoreIsAuthFlag} is * true. * * @param meta {@link DDBPathMetadata} to convert * @param ignoreIsAuthFlag if true, ignore the authoritative flag on item * @return {@code meta} converted to DynamoDB item */ static Item pathMetadataToItem(DDBPathMetadata meta, boolean ignoreIsAuthFlag) { Preconditions.checkNotNull(meta); final FileStatus status = meta.getFileStatus(); final Item item = new Item().withPrimaryKey(pathToKey(status.getPath())); if (status.isDirectory()) { item.withBoolean(IS_DIR, true); if (!ignoreIsAuthFlag) { item.withBoolean(IS_AUTHORITATIVE, meta.isAuthoritativeDir()); } } else { item.withLong(FILE_LENGTH, status.getLen()) .withLong(MOD_TIME, status.getModificationTime()) .withLong(BLOCK_SIZE, status.getBlockSize()); } item.withBoolean(IS_DELETED, meta.isDeleted()); return item; }
/** * The version marker has a primary key whose PARENT is {@code name}; * this MUST NOT be a value which represents an absolute path. * @param name name of the version marker * @param version version number * @param timestamp creation timestamp * @return an item representing a version marker. */ static Item createVersionMarker(String name, int version, long timestamp) { return new Item().withPrimaryKey(createVersionMarkerPrimaryKey(name)) .withInt(TABLE_VERSION, version) .withLong(TABLE_CREATED, timestamp); }