use of com.jcabi.aspects.Cacheable in project jcabi-dynamo by jcabi.
the class AwsTable method keys.
/**
* Get names of keys.
* @return Names of attributes, which are primary keys
* @throws IOException If DynamoDB fails
*/
@Cacheable(forever = true)
public Collection<String> keys() throws IOException {
final AmazonDynamoDB aws = this.credentials.aws();
try {
final long start = System.currentTimeMillis();
final DescribeTableResult result = aws.describeTable(new DescribeTableRequest().withTableName(this.self));
final Collection<String> keys = new LinkedList<String>();
for (final KeySchemaElement key : result.getTable().getKeySchema()) {
keys.add(key.getAttributeName());
}
Logger.info(this, "#keys(): table %s described, in %[ms]s", this.self, System.currentTimeMillis() - start);
return keys;
} catch (final AmazonClientException ex) {
throw new IOException(String.format("Failed to describe \"%s\"", this.self), ex);
} finally {
aws.shutdown();
}
}
Aggregations