These are chat archives for Ruhrpottpatriot/GW2.NET

19th
Feb 2016
ZedTheYeti
@ZedTheYeti
Feb 19 2016 03:31
@Ruhrpottpatriot thanks for that, I'm fairly new to contributing to Open Source projects. As I'm sure you can tell.
Steven Liekens
@StevenLiekens
Feb 19 2016 10:08
what problem does caching within repositories solve?
as opposed to getting data from the repository and caching it elsewhere
Robert Logiewa
@Ruhrpottpatriot
Feb 19 2016 11:56
before requesting data from the api the repository checks if the data is in the cache and still „fresh“. This means, that only stale and not present data will be requested from the api.
Yes ANet caches too, but the most expensive thing for us is the connection build up. Since we don’t want to keep the connection alive the whole time, we can reduce request time.
Steven Liekens
@StevenLiekens
Feb 19 2016 12:00
yes but why does it have to be cached at the repository level? instead of at the caller
Robert Logiewa
@Ruhrpottpatriot
Feb 19 2016 12:01
This also gives a unified endpoint for the user to query. He doesn’t need to worry about getting data from the cache itself, we are doing it for him. If you look at the new layout you’ll see that it is all about simplifying the user’s interface, while keeping most of the operations intact. We don’t need a 1:1 relation with the api, we need to offer sensible operations, that offer great flexibility.
And putting caching in the repository, with the option for the user to change it, we are doing exactly that.
Steven Liekens
@StevenLiekens
Feb 19 2016 12:27
putting caching in the repository sounds like it makes it impossible to bypass
Robert Logiewa
@Ruhrpottpatriot
Feb 19 2016 12:28
Currently in a simple way, yes. But only because I was too lazy to implement a switch for now. Bypassing the cache is a planned feature and I’m currently working on it.
Steven Liekens
@StevenLiekens
Feb 19 2016 12:32
if the cache is outside the repository then bypassing the cache is easy
Robert Logiewa
@Ruhrpottpatriot
Feb 19 2016 12:34
It’s also easy bypass when inside. The most simple solution is a property on the cache class UseCache, which defaults to true. If the user wants to bypass it, he’d set it to false and voilá
Robert Logiewa
@Ruhrpottpatriot
Feb 19 2016 12:59
Look at it this way:
The repository should be the central place to access an API service, it should offer the possibility to get all information a service can offer in the most convinient way possible. It also should offer customisation.
Example: A user only wants to query the API for items, nothing else. He then could download the GW2NET.Items package. He then would be responsible for instantaniating the repository itself, but does that mean we can’t take work off him? No
If we’d move the cache outside of the repository he’d be responsible for caching too. Why should he?
On a more theoretical level: A repository stores data and controls the access to it. Therefore it should be reponsible for caching too. This is also what MSDN tells us.
Steven Liekens
@StevenLiekens
Feb 19 2016 13:05
I was thinking about distributed caching and all that
Robert Logiewa
@Ruhrpottpatriot
Feb 19 2016 13:59
I don’t think that would benefit us that much. Currently the cache uses a SortedSet<T> (might switch toHashSet<T>) to store data (we might need to improve on hashing, btw) and keep access times at O(long. This keeps the cache implementation small and lightweight. With a distributed cache we need to keep more things in mind and implementation would be more complex.