Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
永続化、なに使おう?
Search
n-seki
January 23, 2024
Technology
340
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
永続化、なに使おう?
Ebisu.mobile#4
2024/01/23
n-seki
January 23, 2024
More Decks by n-seki
See All by n-seki
2App, 1Repository
n_seki
0
56
10年もののバグを退治した話
n_seki
0
280
OS間でBluetooth処理を(一部)共通化している話
n_seki
0
110
やってみようMaven!
n_seki
0
390
Try Android Health Connect
n_seki
0
100
Other Decks in Technology
See All in Technology
スキマバイトという雇用形態は存在しないので、雇用期間1日のアルバイト契約を事業者とワーカーが結ぶ手続きを支えるのがタイミーなんです
akitoshiga
0
210
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
200
WasmをRustにする
sansantech
PRO
0
280
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
200
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
120
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
190
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.3k
今さら理解するウェブフォントver.2026
takanorip
3
910
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
360
しろおびから始める!ログ活用の第一歩
shumei_ito
0
960
Running Kotlin + Quarkus with Lambda
nealle
1
4k
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.9k
Designing for Performance
lara
612
70k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Test your architecture with Archunit
thirion
2
2.4k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Odyssey Design
rkendrick25
PRO
2
880
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
What's in a price? How to price your products and services
michaelherold
247
13k
Transcript
永続化、なに使おう? Realm脱却のユースケース 2024/01/23 Ebisu.mobile#4 Naoto Uwaseki
• Naoto Uwaseki ◦ STORES 決済 のAndroidアプリ/SDK の開発 ◦ @n_seki_
( X / Twitter ) / @n-seki (GitHub) AndroidXの中ではRoomが好きです!! →モルモットです。
Androidの永続化の話をします🌵
「Realmから別の技術への移行」を題材に、 Androidの永続化の方法を比較し、 技術選定の流れをダイジェストでお送りします✋
昨年末にRealm脱却対応を行いました🔥 • ある処理にRealmが使われていた • かなり古いバージョン...... • 他の機能ではRealmを使ってない Realm: モバイル端末で使えるデータベース https://github.com/realm
よし、Realmにさよならしよう👋
……どの技術に移行するべきだろう?🤔
……どの技術に移行するべきだろう?🤔 Room? SharedPreferences? Preferences DataStore? Proto DataStore? ……?
どんな永続化技術があるか確認しましょう🌵
永続化しない • そのデータは本当に永続化の必要がありますか? ◦ 永続化した瞬間から考えることが増える ◦ やらないのが一番バグらない • 少し立ち止まって永続化の必要性について思いを馳 せたい
Realm脱却の仕様を確認 • プリミティブな値ではなく、まとまりをもったデータを保 存したい(複数のカラムがある) • アプリがインストールされている間は参照したい ◦ → 永続化は必要そう •
将来的にデータ構造を変更する可能性もある • データ量は少ない
AndroidXの仲間たち🌟
Preferences DataStore • Key-Value形式でのデータ保存 • スレッドセーフ ◦ != SharedPreferences •
ハック:JSONを文字列データとして保存する ◦ 型安全ではない
Preferences DataStore
Preferences DataStore
Proto DataStore • Protocol Buffers ◦ https://protobuf.dev/ • 任意の型のデータを保存できる •
スレッドセーフ/型安全
Proto DataStore
Proto DataStore
Proto DataStore
Proto DataStore
Room • SQLiteを便利に使えるライブラリ • スレッドセーフ/型安全 • マイグレーションもかんたん ◦ AutoMigration (from
2.4.0)
Room
Room
複雑なデータ 型安全 向いている データ量 マイグレーション 永続化しない! - - - DataStore-Shard
✕ 小 ◯ DataStore-Proto ◯ 小 ◯ Room ◯ 大 ◯
Proto DataStore v.s Room
非機能的な観点からも考える ✊
Proto DataStore v.s Room • 他の機能ではRoomを利用している ◦ Roomならメンバー全員が慣れている技術なのでメ ンテナンスも比較的容易 •
ここだけProto DataStoreにすると、将来的にRealmと同 じ道をたどる可能性がある
Roomに決定 👏
実装対応 そしてリリース 🚀
実は、昨日リリースしました 🕺
まとめ • 本当に永続化が必要か、ちょっとだけ立ち止まる • 技術を比較検討する ◦ 型安全やマイグレーションの容易性から、Roomや Proto DataStoreを積極的に採用したい •
仕様以外の観点からも考える ◦ 技術への慣れ(自分/メンバー) ◦ 既存実装との兼ね合い
おしまい 👑