taycaldwell / riot-api-java

Riot Games API Java Library
http://taycaldwell.github.io/riot-api-java/
Apache License 2.0
192 stars 73 forks source link

Caching #30

Closed briceambrosiak closed 8 years ago

briceambrosiak commented 9 years ago

Introduce an optional caching system, with cache duration configurable. This would avoid consuming the limited calls for identical repeated queries.

taycaldwell commented 9 years ago

This is something I would eventually like to add. In the mean time, check out another Riot Games API library, Orianna.

It provides the following features you might be interested in -

adobito commented 9 years ago

To me this seems more of a design issue rather than a technical issue. Adding caches is a piece of cake with Guava, but making an intuitive cache configuration isn't as simple.

From what I remember, you can let Guava expire your cache by time or by amount of items in cache. You could set a single value for each used by every API and just optionally pass it to the constructor. I don't think this is an optimal solution since you might want to cache things differently. For example, summoner data you might want to expire by time, match data you might want to expire based on how many so your RAM doesn't fill up excessively and static data you might not want to ever expire at all.

If we can reach a consensus for a good design that covers most people's use cases, then getting the actual code in should be simple enough.