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
In-Memory Realms を使って API キャッシュした話 / Use In-Mem...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
satoru.sasaki
June 29, 2018
Programming
1.9k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
In-Memory Realms を使って API キャッシュした話 / Use In-Memory Realms
satoru.sasaki
June 29, 2018
More Decks by satoru.sasaki
See All by satoru.sasaki
Dynamic Links with mitene
caad1229
0
1.9k
みてねのAndroid課金開発環境 / Android In-App Purchase Environment
caad1229
0
1.7k
Other Decks in Programming
See All in Programming
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
150
アクセシビリティから考える情報設計
high_g_engineer
0
370
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
110
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
700
XHTMLが残したもの
yosuke_furukawa
PRO
2
750
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.2k
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
150
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
200
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
150
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
790
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
699
190k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Building Adaptive Systems
keathley
44
3.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
It's Worth the Effort
3n
188
29k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Design in an AI World
tapps
1
310
A Soul's Torment
seathinner
7
3.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
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 ͷλΠϛϯά —ΩϟογϡΫϦΞͷλΠϛϯά —ϖʔδϯάɾϢʔβૢ࡞ʹΑΔςʔϒϧͷߋ৽
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠