Fir*_*urn 2 java database amazon-s3 amazon-web-services
使用 Amazon S3(或 S3 兼容的对象存储)作为应用程序的主数据库有哪些限制。
这个库看起来很有前途,有这个 API:
// Setup Dyno
Dyno dyno = DynoClientBuilder
.simple()
.withEndpointConfig("s3.wasabi.sys", "us-east-1")
.withCredentials(ACCESS_KEY, SECRET_KEY)
.withBucket("dyno")
.withKeySpace(":")
.withBufferSize(1024)
.build();
// Here's a sample way to create a "User" entity with Dyno
// First create an entity with user_id this will prevent creation of another user
// with the same username
Entity user = EnityBuilder
.create(dyno)
.with("username", "dino")
.with("user_id")
.build(uuid(), String.class)
.putIfAbsent();
Run Code Online (Sandbox Code Playgroud)
进一步使用此代码:
// Since the username "dino" has been secured we can assign the password simply by
// puting a new entity with the assigned password:
Key key = EnityBuilder
.create(dyno)
.with("user_id", user.getValueString())
.with("password")
.build(sha256("the_password"), String.class)
.putIfAbsent();
Run Code Online (Sandbox Code Playgroud)
还是那句话,使用S3有什么限制?是什么使得使用 S3 作为数据库来执行标准 CRUD 操作和查询变得可行?
Amazon S3实际上是一个非常大的NoSQL数据库。文件名是键,内容是值。
但是,对象的内容是不可变的,因此如果您想“更新”某些数据,则需要完全替换对象的内容。
例如,Amazon.com 实际上使用 S3 作为历史订单的只读 NoSQL 数据库。订单一旦超过一年,将无法退货/更改。因此,数据将导出到 S3 并从数据库中删除。查询速度稍慢,但旧订单很少被访问,所以这是可以接受的。
Amazon S3 有一项称为S3 Select 的功能,允许对单个对象执行 SQL。当从大对象中查找几行而无需下载该对象时,这非常有用。
Amazon Athena还非常适合查询 Amazon S3 中存储的数据。它基于 Presto,允许针对多个对象进行复杂的 SQL 操作,并支持列格式(Parquet、ORC)、分区和压缩。
归档时间: |
|
查看次数: |
2361 次 |
最近记录: |