meraki-analytics / orianna

A Java framework for the Riot Games League of Legends API (http://developer.riotgames.com/).
MIT License
182 stars 56 forks source link

Save RiotAPI.getChampions(); data #23

Closed JeffreyCA closed 9 years ago

JeffreyCA commented 9 years ago

Hi again,

Sorry for all of these questions, please bear with me.

Is there a way to save the data from RiotAPI.getChampions(); and reuse/read that data instead of retrieving the same data from Riot's servers every time? In terms of Android programming, I do not want to retrieve so much data every time I launch my app.

I think I would need to do List<Champion> champions = RiotAPI.getChampions(); and save that to a file somehow and then when I launch my app, I need to read that file and process it? Or is that the wrong way to do it?

(For LoadPolicy.LAZY or LoadPolicy.UPFRONT)

robrua commented 9 years ago

Hey, feel free to email me directly with problems if you don't want to keep opening issues.

There's a DataStore interface that can replace the in-memory caching with RiotAPI.setDataStore(). It'll do exactly what you're looking for. Currently, there's a Hibernate implementation which will use Hibernate to cache things in a RDB. (I don't actually know if this will work for Android, but worth looking in to.)

There's also a (slapped-together and buggy) FileSystemDataStore which will just use serialized files on the filesystem instead of a database.

You might need to edit either of these to get them working properly on Android or implement your own DataStore with an Android-based database, but DataStore is way to do this in Orianna.

JeffreyCA commented 9 years ago

Thanks again, I'll try that out. It sounds pretty complicated though.