Realm Blog

Realm Java 0.82.0 with in-memory Realm support!

We just released a Realm Java update to this website, and to Maven. This release includes new features like in-memory Realms, and updates to the @PrimaryKey and @Index annotations.

In-Memory Realms

It’s now possible to create an in-memory Realm. In-memory Realms are useful when you want the benefits of Realm objects (schema, queries, threading model, etc.) without persistence, but a bit of extra performance. They’re great for temporary caching, per-session details, and so on.

Just set this option when building a RealmConfiguration

// In-Memory RealmConfiguration
RealmConfiguration config = new RealmConfiguration.Builder(context)

Realm realm = Realm.getInstance(config);

The RealmQuery.between() predicate has been removed for link queries. You can still use the predicate for ordinary queries. Realm’s underlaying storage engine does not support the predicate for link queries, and Realm for Android implemented the predicate using two predicates. In some use cases, the results can be counter-intuitive. Likewise, Realm for Swift & Objective-C does not support the predicate for link queries, and for consistency we have decided to remove it.

Other improvements

In addition, @Index annotation can also be applied to byte/short/int/long/boolean/Date. As a consequence of this, @PrimaryKey will now be indexed automatically, which should improve queries performance.

Breaking changes

Since all primary keys are now automatically indexed, your old primary keys of type short and int will need to be migrated to be indexed fields. To do this, you will have to use the Table.addSearchIndex(long columnIndex) method in your migration class.

Here is an example:

   .schemaVersion(2) // Bump schema version
   .migration(new RealmMigration() {
      public long execute(Realm realm, long version);
         if (version == 1) {
            Table table = realm.getTable(Foo.class);
            long keyIndex = table.getColumnIndex("id");
         return version;

See the full changelog for full details.

Thanks for reading. Now go forth and build amazing apps with Realm! As always, we’re around on Stack Overflow, GitHub, and Twitter.

Realm Team

At Realm, our mission is to help developers build better apps faster. We provide a unique set of tools and platform technologies designed to make it easy for developers to build apps with sophisticated, powerful features — things like realtime collaboration, augmented reality, live data synchronization, offline experiences, messaging, and more.

Everything we build is developed with an eye toward enabling developers for what we believe the mobile internet evolves into — an open network of billions of users and trillions of devices, and realtime interactivity across them all.

Get more development news like this