Realm is a cross-platform mobile database that provides an easy to use object-oriented API. It is fast, small in size, and fully ACID compliant. Realm has gained popularity with over 20,000 iOS developers and 5,000 Android developers using it within the first few weeks of release. Realm aims to be simple, fast and modern to use across threads. Some key lessons learned from building Realm include aiming high, listening to user feedback, and prioritizing usability over raw performance. Future plans include adding encryption and other advanced features.
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
#MBLTdev: Уроки, которые мы выучили, создавая Realm
1. Realm and
Lessons Learned building it
{MBLT}DEV ‘14
Brian Munkholm,
VP Engineering @realm
bm@realm.io
@brianMunkholm
2. Menu:
What is Realm?
How popular?
Why use Realm? Feedback
Design goals & fulfilment - API examples
Lessons Learned
The future
3. What is Realm?
• Modern mobile database - replace SQLite+ORMs
• Easy: Object-oriented, but not an ORM
• Safe: full ACID properties
• Cross-platform: C++ core (3 years dev)
• Small: compact data, object == DB (no copy!)
• Fast
• Free: open source!
4. Realm for iOS
Used by >20,000 developers
worldwide in < 8 weeks!
Including ~1,000 in or very close to
production
>2200 GitHub Stars!
(Parse: 10k in 8 mon)
5. Realm for Android
- launched 1 month ago
Used by >5,000 developers
worldwide the 1’st week!
First apps in production
>700 GitHub Stars in 2 weeks
(GreenDao has 1592, ORMlite 307 after years!)
9. Cloth
a beautifully designed
personal outfit diary
>350k users
Uses Realm for all data
handling
took over a 2 year-old
codebase and ported it to
Realm in 1 day.
clothapp.com
reallyseth.com
10. Beanflow
Full POS & inventory app (w/
offline mode)
Uses Realm as network cache
for all data
“I don't have any plans to go
back to Core Data anytime
soon. I really like Realm.”
sebastiandobrincu.com
www.beanflow.com
11. Common benefits
• Save time - save $$$
• Make faster & better apps
• Uses less memory and disk
• Free (de)serialisation
• cross platform (iOS, Android, ++)
• cross language
12. Design Goals
1. Simple
2. Fast
3. Modern
to learn
to maintain
to use across threads
14. Models
public class Dog extends RealmObject {
// Fields
private String name;
private int age;
// + Getters and Setters…
}
15. Writes
// Obtain a Realm instance in each thread
Realm realm = Realm.getInstance(this);
// ACID transactions give you easy thread-safety
realm.beginTransaction();
Dog dog = realm.createObject(Dog.class);
dog.setName("Rex");
dog.setAge(3);
// Full commit to disk (or memory)
realm.commitTransaction();
17. Relationships
public class Person extends RealmObject {
private String name;
private Dog bestDog; // One-One relations
private RealmList<Dog> dogs; // One-Many relations
…
}
realm.beginTransaction();
Person person = realm.createObject(Person.class);
person.setName("Tim");
person.getDogs().add(dog);
realm.commitTransaction();
18. Thread-safety: All access is the same
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void… voids) {
Realm realm = Realm.getInstance(this);
realm.beginTransaction();
Person person = realm.createObject(Person.class);
person.setName("Tim");
realm.commitTransaction();
return null;
}
}.execute();
19. Thread-safety:
• Writes cannot conflict - they block
• No need to merge data sources, ever.
• Reads are consistent as soon as the
write completes
20. 2. Fast
BIG disclaimer!
Use benchmarks as rough indicator
Measure your own senarios
24. Lesson one
Aim high!
• Worlds best product
• Solid funding from the best
• 100% dedicated team
25. Lesson two
Listen to the users / community
• Ask users actively
• Listen, understand their needs
and react quickly
• It takes time!
26. Lesson three
Performance is great - but
usability is king!
• and eats performance…
• Android/Java reflection is SLOW
• but dont’ give up
27. Add a new object first time
• Runtime code generation
• Use lower level APIs
• Compile-time code
generation
• Cache all the introspection
calls
100
75
50
25
0
4 sec!!!
Runtime Runtime+ Compile Time Cache
28. The future:
• Encryption
• Handover results between threads
• Dynamic API / Migration
• Advanced Query
• Synchronisation
• What do you want for xmas?
29. Thanks for your support!!!
Watch or Influence?
Feedback :
realm.io bm@realm.io
#Realm #BrianMunkholm