Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
In-Memory Realms を使って API キャッシュした話 / Use In-Mem...
Search
satoru.sasaki
June 29, 2018
Programming
0
1.8k
In-Memory Realms を使って API キャッシュした話 / Use In-Memory Realms
satoru.sasaki
June 29, 2018
Tweet
Share
More Decks by satoru.sasaki
See All by satoru.sasaki
Dynamic Links with mitene
caad1229
0
1.8k
みてねのAndroid課金開発環境 / Android In-App Purchase Environment
caad1229
0
1.6k
Other Decks in Programming
See All in Programming
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
2
270
CursorはMCPを使った方が良いぞ
taigakono
1
180
GoのGenericsによるslice操作との付き合い方
syumai
3
690
プロダクト志向なエンジニアがもう一歩先の価値を目指すために意識したこと
nealle
0
110
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
380
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
800
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
390
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
4
950
来たるべき 8.0 に備えて React 19 新機能と React Router 固有機能の取捨選択とすり合わせを考える
oukayuka
2
860
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
800
エラーって何種類あるの?
kajitack
5
310
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
230
Featured
See All Featured
Building an army of robots
kneath
306
45k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Why Our Code Smells
bkeepers
PRO
337
57k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Statistics for Hackers
jakevdp
799
220k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Building Adaptive Systems
keathley
43
2.6k
Designing for humans not robots
tammielis
253
25k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
In-Memory Realms ͬͯ API Ωϟογϡͨ͠ ΈͯͶͷMeetup #1 2018-06-27 satoru.sasaki
ࣗݾհ —ࠤʑ ڿ (@caad1229) —201510݄ೖࣾ —ࡢ SNSϛΫγΟ -> ΈͯͶ ʹҠಈ
—झຯϨίʔυͰ Jazz ௌ͘͜ͱ
ΈͯͶΞϓϦͱrealm —ΈͯͶͰϢʔβͷϝσΟΞ ใΛ realm ͰΩϟογϡ͍ͯ͠ Δ —ࠩಉظͱશମಉظͰ realm ʹ ಉظ
—ىಈ࣌ɾ௨ड৴ɾΞοϓϩ ʔυ࣌
ΈͯͶΞϓϦͱ Architecutre —Android ͷ৽نػೳ MVVM Ͱ࣮ —iOS ͱઃܭΛἧ͑ΔͨΊʹ CleanArchitecture Λ͍ͬͯ
Δͱ͜Ζ͋Δ
API ΩϟογϡΛ͏ܦҢ —Ϣʔβͷʹ৮ΕΔػձ͕ଟ͍͕ɺߋ৽͕සൟͰͳ͍ —ը໘͕දࣔ͢Δͨͼʹ fetch ͢Δඞཁ͕ͳ͍ —Push ͳͲͰ࠷৽Λऔಘ͢Ε͍͍ఔ
In-memory Realm ʹ͍ͭͯ —σʔλϝϞϦॻ͔ΕΔ —Realm ΠϯελϯεͷࢀরΧϯλ͕ 0 ʹͳΔͱσ ʔλ͕ফ͑Δ —ΞϓϦىಈதͰσʔλΛอ͍࣋ͨ͠߹
Application ΫϥεͰ Realm ΠϯελϯεΛอ࣋
In-memory Realm ͷಋೖ —Application Ͱ realm ΠϯελϯεΛอ࣋ open class CustomApplication
: Application() { private var realm: Realm? = null : }
In-memory Realm ͷಋೖ —onCreate Ͱੜͱอ࣋ override fun onCreate() { super.onCreate()
val config = RealmConfiguration.Builder() .name("in-memory.realm") .inMemory() .build() // อ࣋͢Δ realm = Realm.getInstance(config) }
In-memory Realm ͷಋೖ —onTerminate Ͱഁغ override fun onTerminate() { realmInMemory?.close()
super.onTerminate() }
cache ػߏͷͨΊͷઃܭ —MVVM ͏
Data ͷѻ͍ —Mapper Λͬͯڞ௨ Object ʹ ͢Δ —Mapper ʹม͢Δ interface
Mapper<E, D> { fun mapFromEntity(type: E): D fun mapToEntity(type: D): E }
Cache ͷσʔλ —RealmObject —ϦϨʔγϣϯ͕؆୯ʹͰ͖Δ RealmList<T> Λ͏
Repository —Local ͱ Remote Λ͏ —cache ͷอଘͱऔಘϩδοΫ —Local ͔Βऔಘͯ͠ɺͳ͚Ε
Remote ͔Β fetch ͢Δ —ڧ੍తʹ Remote ͔Βऔಘ Ͱ͖ΔΑ͏ʹ͢Δ
Repository
Demonstration
Demonstration Qiita هࣄҰཡΛऔಘ͢ΔΞϓϦ https://github.com/caad1229/apicache dagger2 okHttp3 retrofit2 rxJava2 realm Glide
՝ͱ͔ —expire ͷλΠϛϯά —ΩϟογϡΫϦΞͷλΠϛϯά —ϖʔδϯάɾϢʔβૢ࡞ʹΑΔςʔϒϧͷߋ৽
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠