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-Memory Realms
Search
satoru.sasaki
June 29, 2018
Programming
0
1.6k
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.6k
みてねのAndroid課金開発環境 / Android In-App Purchase Environment
caad1229
0
1.5k
Other Decks in Programming
See All in Programming
Goのmultiple errorsについて (2024年4月版)
syumai
1
480
코틀린으로 멀티플랫폼 만들기
pangmoo
0
150
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
330
ScalarDBを用いたマイクロサービスにおけるデータ管理 (Database Engineering Meetup #2)
scalar
0
110
Rails と人魚の話/rails-and-mermaid
sanfrecce_osaka
0
100
What We Can Learn From OSS
inouehi
0
420
Front-end application development, Symfony-style(s)
dunglas
2
2k
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
700
ゆるい個人開発のススメ
kuroppe1819
10
980
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.1k
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
120
Ruby Function Composition
bkuhlmann
1
330
Featured
See All Featured
How to Ace a Technical Interview
jacobian
272
22k
A better future with KSS
kneath
231
16k
How STYLIGHT went responsive
nonsquared
92
4.8k
Building a Scalable Design System with Sketch
lauravandoore
456
32k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
120
39k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
jQuery: Nuts, Bolts and Bling
dougneiner
59
7.1k
The Art of Programming - Codeland 2020
erikaheidi
42
12k
Designing on Purpose - Digital PM Summit 2013
jponch
110
6.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Raft: Consensus for Rubyists
vanstee
132
6.3k
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 ͷλΠϛϯά —ΩϟογϡΫϦΞͷλΠϛϯά —ϖʔδϯάɾϢʔβૢ࡞ʹΑΔςʔϒϧͷߋ৽
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠