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

Problem with Changing Regions #21

Closed JeffreyCA closed 9 years ago

JeffreyCA commented 9 years ago

If I want to process data for a summoner with the same name, but on different regions/servers, it gives me the same data as the account on the first region, as shown below.

It seems RiotAPI.setMirror(Region.LAN); and RiotAPI.setRegion(Region.LAN); are not changing the region?

   RiotAPI.setMirror(Region.NA);
   RiotAPI.setRegion(Region.NA);
   RiotAPI.setAPIKey("KEY_HERE");

   Summoner summoner = RiotAPI.getSummonerByName("TheOddOne");
   System.out.println(summoner.getID());

   RiotAPI.setMirror(Region.LAN);
   RiotAPI.setRegion(Region.LAN);

   summoner = RiotAPI.getSummonerByName("TheOddOne");
   System.out.println(summoner.getID());

The code above gives me the same output, even though they should be different. This happens for both RiotAPI and AsyncRiotAPI.

JeffreyCA commented 9 years ago

It doesn't do that for BaseRiotAPI though:

        BaseRiotAPI.setMirror(Region.NA);
        BaseRiotAPI.setRegion(Region.NA);
        BaseRiotAPI.setAPIKey("744e79b3-a84f-49c2-aa78-4fab3d9b0401");

        Map<String, Summoner> summoners = BaseRiotAPI
                .getSummonersByName("TheOddOne");
        Summoner summoner = summoners.get("theoddone");

        System.out.println(summoner.getId());

        BaseRiotAPI.setMirror(Region.LAN);
        BaseRiotAPI.setRegion(Region.LAN);

        summoners = BaseRiotAPI.getSummonersByName("TheOddOne");
        summoner = summoners.get("theoddone");

        System.out.println(summoner.getId());

The code above gives me different values, which is the way it should be

robrua commented 9 years ago

Hey - this is a result of the way caching is set up right now. Summoners are automatically cached internally in Orianna, and the cache is currently not separated by region. The existing workaround would probably be to use RiotAPI.setDataStore(new VoidDataStore()) to disable caching.

JeffreyCA commented 9 years ago

Alright, thanks

dnlbauer commented 8 years ago

This issue should not be closed until its fixed imo. Just ran into the same problem :(