R2
CLOUDFLARECloudflare R2 through the asynchronous AWS SDK client.
R2 setup →R2D1 / MODULAR JAVA PERSISTENCE
Choose one DocumentStore for complete documents and one IndexStore for indexed lookup. R2D1 keeps the collection API the same across the supported backends and integrations.
R2D1 combines one DocumentStore with one IndexStore. Select one backend from each column, follow its setup guide, and then use the shared collection API.
Authoritative serialized content, reads by identifier, and the document list.
Document identifiers and explicitly indexed fields for filtering and sorting.
Once the two backends are configured, every pairing uses the same annotations, collection lifecycle, mutation methods, and indexed query builder.
@Document("users")
record User(@Id String id, @Index String country, @Index long score) {}
R2D1 database = R2D1.builder()
.collectionFactory(new PersistenceCollectionFactory(
documentStore, indexStore, documentCodec, indexStore::initialize))
.build();
R2D1Collection<User> users = database.collection(User.class);
users.put(new User("user-123", "NZ", 42));
Page<User> page = users.query()
.where("country").eq("NZ")
.sortBy("score", SortDirection.DESC)
.limit(20)
.fetch();The complete setup, adapter choices, and lifecycle rules are covered in Getting Started.
The core artifact covers the common API and Cloudflare backends. Add the module that supplies local files, JDBC indexing, or Micronaut wiring.
dev.nexcraft:r2d1Common collection API plus the R2 DocumentStore and D1 IndexStore adapters.
Module setup →dev.nexcraft:r2d1-jdbcH2, HSQLDB, and local SQLite indexes behind an application-owned DataSource.
JDBC setup →dev.nexcraft:r2d1-filesystemCanonical local document files with atomic replacement and explicit executor ownership.
Filesystem setup →dev.nexcraft:r2d1-micronautMicronaut 5 bean configuration around the same framework-neutral collection API.
Micronaut setup →Set up one document store, one index store, define the metadata, and open the collection.